本文整理匯總了Java中org.galagosearch.core.tools.Search.SearchResult類的典型用法代碼示例。如果您正苦於以下問題:Java SearchResult類的具體用法?Java SearchResult怎麽用?Java SearchResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SearchResult類屬於org.galagosearch.core.tools.Search包,在下文中一共展示了SearchResult類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performSearch
import org.galagosearch.core.tools.Search.SearchResult; //導入依賴的package包/類
private SearchResult performSearch(HttpServletRequest request) throws Exception {
String query = request.getParameter("q");
String startAtString = request.getParameter("start");
String countString = request.getParameter("n");
int startAt = (startAtString == null) ? 0 : Integer.parseInt(startAtString);
int resultCount = (countString == null) ? 10 : Integer.parseInt(countString);
SearchResult result = search.runQuery(query, startAt, resultCount, true);
return result;
}
示例2: handleSearchXML
import org.galagosearch.core.tools.Search.SearchResult; //導入依賴的package包/類
public void handleSearchXML(HttpServletRequest request, HttpServletResponse response) throws IllegalStateException, IllegalArgumentException, IOException, Exception {
SearchResult result = performSearch(request);
PrintWriter writer = response.getWriter();
XMLOutputter outputter = new XMLOutputter(writer, "UTF-8");
response.setContentType("text/xml");
outputter.startTag("response");
writer.append("<response>\n");
for (SearchResultItem item : result.items) {
outputter.startTag("result");
outputter.startTag("identifier");
outputter.pcdata(item.identifier);
outputter.endTag();
outputter.startTag("title");
outputter.pcdata(item.displayTitle);
outputter.endTag();
outputter.startTag("url");
outputter.pcdata(item.url);
outputter.endTag();
outputter.startTag("snippet");
outputter.pcdata(item.summary);
outputter.endTag();
outputter.startTag("rank");
outputter.pcdata("" + item.rank);
outputter.endTag();
outputter.startTag("metadata");
for (Entry<String, String> entry : item.metadata.entrySet()) {
outputter.startTag("item");
outputter.startTag("key");
outputter.pcdata(entry.getKey());
outputter.endTag();
outputter.startTag("value");
outputter.pcdata(entry.getValue());
outputter.endTag();
}
outputter.endTag();
}
}