本文整理汇总了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();
}
}