Hi there,
I am currently trying to use a fulltext search to search for datas in my notes database using the notes c++ api.
Assuming my database already contains the following datas,
FirstName:John LastName:Smith
FirstName:Oliver LastName:John
FirstName:Mo LastName:Johnson
Whenever i search for the name ‘John’, All Three Names will appear, which works perfectly fine.
However i would like to know, if there is anyway that i can know which of the field is found? for example for my example, i will need to know the document John Smith is retrieved due to the match in FirstName.
The document Oliver John is retrieved due to the match in LastName.
The document Mo Johnson is retrieved due to the match in LastName.
Is there anyone that can help me in this? Thanks to everyone that can provide me with any clue to start up on this.
Below is my sample code of Full Text Search.
LNNotesSession Session;
LNDatabase db;
LNDocument EntryDoc;
LNINT count = 0, maintopics = 0;
LNString TheUser,MyField,LnstrDocFirst,LNStrBuffer;
LNViewFolder view; //view Contacts
LNVFEntry entry,NavEntry; // Working entry
LNText LastName,EntryDocFirst;
LNFormFieldArray FormFieldArray;
LNFormField MyFormField;
LNVFNavigator nav;
LNUniversalID MyUNID;
int MyCount=0,dec,sign,i;
CString StrBuffer,CStrBuffer,CStrFieldName,NumStrBuffer;
Session.Init();
Session.GetDatabase("C:\\Program Files\\lotus\\notes\\data\\names.nsf", &db);
db.Open();
db.CreateFTIndex(LNFTINDEXFLAGS_INDEX_ENCRYPTED_FIELDS);
db.GetViewFolder("Contacts", &view);
view.Open();
StrBuffer = "John*";
MyTestString = StrBuffer;
LNString LNTesting = MyTestString;
if(view.FTSearch(LNTesting,&nav) == 0)
{
MessageBox("Found");
count = nav.GetEntryCount();
//MyCount = count;
NumStrBuffer = _fcvt(count,0,&dec,&sign);
MessageBox(NumStrBuffer);
if(nav.GotoFirst(&NavEntry) == 0)
MessageBox("Moved to first topic");
for(i=0;i<count;i++)
{
if(NavEntry.GetDocument(&EntryDoc) == 0)//0 if can get document. If unsuccessful, will be 1
{
EntryDoc.Open();
LNStrBuffer = "FullName";
EntryDoc.GetItem(LNStrBuffer, &EntryDocFirst);//Get FullName of the Entry as LNTEXT
EntryDocFirst.GetText(&LnstrDocFirst);//EntryDocFirst is LNTEXT so must change to LNSTRING
MessageBox(LnstrDocFirst);
EntryDoc.Close();
}
nav.GotoNext(&NavEntry);
}
}
view.Close();
db.Close();
Session.Term();