The following is sample code for the Search class:
PortalSession session = null; Search search; try { /* * Issue a natural language query */ int numResults = search.doQuery(session, "the text of the query goes here", "", // search all databases "", // no date range specified 50, // return docs with a weight of 50 or more 10); // limit results to 10 documents System.out.println("Number of results found = " + numResults); /* * Loop through the result set and print out all * the available information for each document. */ int j = 0; while (search.getNextRecord()) { j++; System.out.println("\nRecord " + j + ":"); System.out.println("Doc id = " + search.getDocId()); System.out.println("Weight = " + search.getDocWeight()); System.out.println("Url = " + search.getDocUrl()); System.out.println("Title = " + search.getDocTitle()); System.out.println("Summary: " + search.getDocSummary()); System.out.println("Content: " search.getDocContent()); } /* * Disconnect for the search engine */ search.remove(); } catch (Exception e) { System.out.println("Error: " + e.toString()); }
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |