Thursday, February 17, 2011

Oracle UCM GET_SEARCH_RESULTS service with full text search

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 special case and most of situations UCM will throw an exception if you not use them well. During my tests I was able to develop one solution which works very well for me doing full text search and here is it:
1 final IdcClientManager idcManager = new IdcClientManager();
2 final IdcClient idcClient = idcManager.createClient("idc://");
3 final IdcContext idcContext = new IdcContext("sysadmin");
5 final DataBinder binder = idcClient.createBinder();
7 // populate the binder with the parameters
8 binder.putLocal ("IdcService", "GET_SEARCH_RESULTS");
9 binder.putLocal ("QueryText", "dDocFullText <substring> <qsch>"+yourSearchWordOrWords+"</qsch>");
10 binder.putLocal ("SearchEngineName", "databasefulltext");
11 binder.putLocal ("ResultCount", "20");
13 // execute the request
14 ServiceResponse response = idcClient.sendRequest (idcContext, binder);
16 // get the binder
17 DataBinder serverBinder = response.getResponseAsBinder ();
18 DataResultSet resultSet = serverBinder.getResultSet ("SearchResults");
20 // loop over the results
21 for (DataObject dataObject : resultSet.getRows ()) {
22 System.out.println ("Title is: " + dataObject.get ("dDocTitle"));
23 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 your search 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 you want to replace the full text search with something more specific, you can read this article from Kyle's Blog here.

No comments:

Post a Comment