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


Java Sort.rewrite方法代碼示例

本文整理匯總了Java中org.apache.lucene.search.Sort.rewrite方法的典型用法代碼示例。如果您正苦於以下問題:Java Sort.rewrite方法的具體用法?Java Sort.rewrite怎麽用?Java Sort.rewrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.search.Sort的用法示例。


在下文中一共展示了Sort.rewrite方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: search

import org.apache.lucene.search.Sort; //導入方法依賴的package包/類
/**
 * Finds the top {@code count} hits for {@code query} and sorting the hits
 * by {@code sort}.
 *
 * @param query
 *            the {@link Query} to search for
 * @param sort
 *            the {@link Sort} to be applied
 * @param count
 *            the max number of results to be collected
 * @param fields
 *            the names of the fields to be loaded
 * @return the found documents
 */
public List<Document> search(Query query, Sort sort, Integer count, Set<String> fields) {
	try {
		indexWriter.commit();
		IndexReader reader = DirectoryReader.open(directory);
		IndexSearcher searcher = new IndexSearcher(reader);
		sort = sort.rewrite(searcher);
		TopDocs topDocs = searcher.search(query, count, sort);
		ScoreDoc[] scoreDocs = topDocs.scoreDocs;
		List<Document> documents = new LinkedList<>();
		for (ScoreDoc scoreDoc : scoreDocs) {
			Document document = searcher.doc(scoreDoc.doc, fields);
			documents.add(document);
		}
		searcher.getIndexReader().close();
		return documents;
	} catch (IOException e) {
		throw new FhirIndexException(e, "Error while searching");
	}
}
 
開發者ID:jmiddleton,項目名稱:cassandra-fhir-index,代碼行數:34,代碼來源:LuceneRAMIndex.java

示例2: ReRankCollector

import org.apache.lucene.search.Sort; //導入方法依賴的package包/類
public ReRankCollector(int reRankDocs,
                       int length,
                       Query reRankQuery,
                       double reRankWeight,
                       SolrIndexSearcher.QueryCommand cmd,
                       IndexSearcher searcher,
                       Map<BytesRef, Integer> boostedPriority) throws IOException {
  super(null);
  this.reRankQuery = reRankQuery;
  this.reRankDocs = reRankDocs;
  this.length = length;
  this.boostedPriority = boostedPriority;
  Sort sort = cmd.getSort();
  if(sort == null) {
    this.mainCollector = TopScoreDocCollector.create(Math.max(this.reRankDocs, length),true);
  } else {
    sort = sort.rewrite(searcher);
    this.mainCollector = TopFieldCollector.create(sort, Math.max(this.reRankDocs, length), false, true, true, true);
  }
  this.searcher = searcher;
  this.reRankWeight = reRankWeight;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:23,代碼來源:ReRankQParserPlugin.java

示例3: weightSort

import org.apache.lucene.search.Sort; //導入方法依賴的package包/類
/** Returns a weighted sort according to this searcher */
public Sort weightSort(Sort sort) throws IOException {
  return (sort != null) ? sort.rewrite(this) : null;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:5,代碼來源:SolrIndexSearcher.java


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