当前位置: 首页>>代码示例>>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;未经允许,请勿转载。