03-04-2013 03:40 AM
03-04-2013 12:02 PM
The search should formatted as XML, so you may need to make use of XML escape sequences. Here is an example search:
IRecordListPtr pMatches;
if( (iRet=pDB->Search("<ENQuery><FlatQuery>('Year' IS GREATER THAN [1980])</FlatQuery></ENQuery>",pRecordList,&pMatches)) != kServiceNoErr )
gwOut << "FAILURE: IDatabase:earch " << iRet << "\n";
else
gwOut << "SUCCESS: IDatabase:earch (" << pMatches->GetCount()<< ")\n";
03-04-2013 04:16 PM
Hello, thanks a lot for your answer.
I' m sorry for my short example, but the searchstring is formatted as XML. Here is the "longer version":
[...]
IStringPtr pKeyword = RS::CreateInstance<IStringImp>();
pKeyword->assign("Title");
// BUILD XML
std::string sXMLSearch = "<ENQuery><FlatQuery>('Title' IS [";
sXMLSearch.append(pKeyword->c_str());
sXMLSearch.append("])</FlatQuery></ENQuery>");
// SEARCH
if( (iRet=pDBMain->Search(sXMLSearch.c_str(), pAllListMain, &pMatches)) != kServiceNoErr )
[...]
This usually works fine. But if there are parentheses in the title no items will be found. The same search done via the user interface works fine.
e.g.
1) pKeyword->assign("Title one"); // FOUND
2) pKeyword->assign("Title (two)"); // NOT FOUND
3) UI: Title is "Title (two)" // FOUND
Because the items will be found via UI, I´m not sure if i have to escape the parentheses or maybe there is a flag which I have to set.
Best regards
Christian