Oracle UCM GET_SEARCH_RESULTS service with full text search

Posted by Lyudmil Pelov on Oracle Blogs See other posts from Oracle Blogs or by Lyudmil Pelov
Published on Thu, 17 Feb 2011 21:38:12 +0200 Indexed on 2011/02/17 23:30 UTC
Read the original article Hit count: 809

Filed under: Error when finding categories...
Newly I was working on portlet which should be able to do full text search through the UCM documents and I was experimenting with the Ridc and also with the CIS API's. There are some ticks you may take care of, for example using quotes is a very spacial case and most of situations UCM will throw an exception if you not use them well. So during my tests I was able to develop one solution which works very well for me doing full text search and here is it:

final IdcClientManager idcManager = new IdcClientManager();
final IdcClient idcClient = idcManager.createClient("idc://127.0.0.1:4444");
final IdcContext idcContext = new IdcContext("sysadmin");

final DataBinder binder = idcClient.createBinder();
// populate the binder with the parameters
binder.putLocal ("IdcService", "GET_SEARCH_RESULTS");
binder.putLocal ("QueryText", "dDocFullText <substring> <qsch>"+yourSearchWordOrWords+"</qsch>"); 
binder.putLocal ("SearchEngineName", "databasefulltext");
binder.putLocal ("ResultCount", "20");
// execute the request
ServiceResponse response = idcClient.sendRequest (idcContext, binder);
// get the binder
DataBinder serverBinder = response.getResponseAsBinder ();
DataResultSet resultSet = serverBinder.getResultSet ("SearchResults");
// loop over the results
for (DataObject dataObject : resultSet.getRows ()) {
System.out.println ("Title is: " + dataObject.get ("dDocTitle"));
System.out.println ("Author is: " + dataObject.get ("dDocAuthor"));
}


Nothing special so far except the line which declares the full text search. To be able to proceed with the full text search you have to use dDocFullText attribute inside the search query. The tag <substring> is the same as 'like'. Also you have to put your searching string or words in quotes which could be a problem sometime, so I used the tag <qsch>. Using this tag you can have quotes now inside you searching string without to break the code and get parsing exceptions.

To be able to test the example, you do have to enable full text search inside UCM. To do this follow the steps for example from this blog here and then re-index the documents in UCM.

There is also one very nice article about how to define UCM queries if want to replace the full text search with something more specific, you can read this article from Kyle's Blog here.

© Oracle Blogs or respective owner