Sitemap | EndNote
Showing results for 
Search instead for 
Do you mean 
Posts: 6
Registered: ‎03-04-2013
0 Kudos

Problem when using IDatabasePtr-->Search

Hello, I try to build a small plugin which uses the "IDatabasePtr-->Search('Title' is [....])" function. Using "IDatabasePtr-->Search('Title' IS [searchstring], ..., ...)" works fine in most cases. But when the title contains parenthesis, the item will not be found. Using the UI search with the same searchstring works fine. Question: Do I have to escape the parenthesis in the search string? Or has anyone another idea what this could be(encoding,....)? Best regards Christian
Posts: 213
Registered: ‎03-28-2008
0 Kudos

Re: Problem when using IDatabasePtr-->Search

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:Smiley Frustratedearch " << iRet << "\n";
            gwOut << "SUCCESS: IDatabase:Smiley Frustratedearch (" << pMatches->GetCount()<< ")\n";

Peter Travis

Thomson Reuters
Tel +1 800 336 4474

Better Decisions Faster
Thomson Reuters and its product names and acronyms used herein are trademarks, service marks, and registered trademarks used under license.
Posts: 6
Registered: ‎03-04-2013
0 Kudos

Re: Problem when using IDatabasePtr-->Search

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>();        
        // BUILD XML
        std::string sXMLSearch = "<ENQuery><FlatQuery>('Title' IS [";
        // 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.


    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