IBM Content Manager, Version 8.5           

Creating combined parametric and text search: Java

Combining parametric and text searches in Java™ involves five steps.

  1. Create an ICM datastore and connect to it.
  2. Generate the combined query string.
    String queryString =
           "//Journal_Article [Journal_Author/@LastName = \"Richardt\"" +
           " AND contains-text (@Text, \" 'Java' & 'XML' \")=1]";
  3. Use the DKNVPair array to package the options. Always specify the retrieve options (among any other query options) to request the data that you plan to use and enable optimizations.
    DKNVPair parms[] = new DKNVPair[3];
    String strMax = "5";
    parms[0] = new DKNVPair(DKConstant.DK_CM_PARM_MAX_RESULTS, 5);
    DKRetrieveOptionsICM dkRetrieveOptions = 
    	DKRetrieveOptionsICM::createInstance(dsICM); 
    dkRetrieveOptions.baseAttributes(true); 
    parms[1] = new DKNVPair(DKConstant.DK_CM_PARM_RETRIEVE, dkRetrieveOptions);
    parms[2] = new DKNVPair(DKConstant.DK_CM_PARM_END, null);
  4. Execute the combined query in one of three different ways: evaluate, execute, and executeWithCallback.
    DKResults resultsCollection =
    (DKResults)dsICM.evaluate(queryString,
    DKConstant.DK_CM_XQPE_QL_TYPE, parms);
  5. Process the results. The procedure for handling the results depends on which execution method you used.

For a complete sample and additional documentation, see the SSearchICMAPI education sample in IBMCMROOT/samples/java/icm.



Feedback

Last updated: December 2013
dcmaq027.htm

© Copyright IBM Corporation 2013.