Combining parametric and text searches in Java™ involves five steps.
- Create an ICM datastore and connect to it.
- Generate the combined query string.
String queryString =
"//Journal_Article [Journal_Author/@LastName = \"Richardt\"" +
" AND contains-text (@Text, \" 'Java' & 'XML' \")=1]";
- 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);
- 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);
- 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.