Close
dtSearch Text Retrieval Engine Programmer's Reference
dtsOnIndexWordInfo Structure

Used to modify words, or create additional words, as text is indexed.

File: dtsearch.h

Syntax
C++
struct dtsOnIndexWordInfo { const char * originalWord; long positionInFile; long iWhichCallback; long fShouldIndex; long nAdditionalWords; char wordToIndex[512]; };

The dtsOnIndexWordInfo structure is used with the pOnIndexWordFn callback in dtsIndexJob to provide a way to modify the words in a document as they are being indexed. Some possible uses of this callback include: (1) Customizing the character handling for certain characters; (2) Excluding certain words from being indexed; or (3) adding variations on a word. 

Example (from the textdemo sample application): 

 

// Demonstrates how the OnIndexWord callback function can be used to // modify text being indexed. In this case, each word is indexed along with an // inverted version of the word. void OnIndexWord_Inverter(void *pData, dtsOnIndexWordInfo* pInfo) { // First time we are called for a word, just request another callback if (pInfo->iWhichCallback == 0) { pInfo->nAdditionalWords = 1; return; } // Second time we are called for a word, return the inverted version if (pInfo->iWhichCallback == 1) { int l = strlen(pInfo->originalWord); if (l >= sizeof pInfo->wordToIndex) l = sizeof pInfo->wordToIndex-1; for (int i = 0; i < l; ++i) pInfo->wordToIndex[i] = pInfo->originalWord[l-i-1]; pInfo->wordToIndex[l] = '0'; } }