Created
May 16, 2012 06:56
-
-
Save write2munish/2708174 to your computer and use it in GitHub Desktop.
Using OmniFind search in Portal Applications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a valid Application ID that will be used | |
// by the Search Node to authorize access to the collection | |
ApplicationInfo appinfo = factory.createApplicationInfo(applicationName); | |
appinfo.setPassword(applicationPassword); | |
// create a new Properties object. | |
Properties config = new Properties(); | |
config.setProperty("hostname", "OmniFindHostName"); | |
config.setProperty("port", "80"); | |
config.setProperty("timeout", "60"); | |
config.setProperty("username", "websphereUser"); | |
config.setProperty("password", "webspherePassword"); | |
// obtain the OmniFind specific SIAPI Search factory implementation | |
SearchFactory factory = (SearchFactory) | |
Class.forName("com.ibm.es.api.search.RemoteSearchFactory").newInstance(); | |
// obtain the Search Service implementation | |
SearchService searchService = factory.getSearchService(config); | |
// obtain a Searchable object to the specified collection ID | |
Searchable searchable = null; | |
try { | |
searchable = searchService.getSearchable(appinfo, collectionId); | |
} catch (SiapiException e) {return;} | |
// create a new Query object using the specified query string | |
Query q = factory.createQuery("search terms go here"); | |
// execute the search. A ResultSet object will be returned | |
ResultSet rset = null; | |
try { | |
rset = searchable.search(q); | |
} catch (SiapiException e) { return; } | |
Result r[] = rset.getResults(); | |
for (int k = 0; k < r.length; k++) { | |
//Print the results | |
out.println("Result " + k + ": " + r[k].getDocumentID()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment