當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchResult類代碼示例

本文整理匯總了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;
}
 
開發者ID:jjfiv,項目名稱:galagosearch,代碼行數:10,代碼來源:SearchWebHandler.java

示例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();
    }
}
 
開發者ID:jjfiv,項目名稱:galagosearch,代碼行數:47,代碼來源:SearchWebHandler.java


注:本文中的org.galagosearch.core.tools.Search.SearchResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。