org.apache.lucene.search.Sort.needsScores()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中org.apache.lucene.search.Sort.needsScores()方法的一些代码示例,展示了Sort.needsScores()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sort.needsScores()方法的具体详情如下:
包路径:org.apache.lucene.search.Sort
类名称:Sort
方法名:needsScores

Sort.needsScores介绍

[英]Returns true if the relevance score is needed to sort documents.
[中]如果排序文档需要相关性分数,则返回true。

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

  1. public SimpleFieldCollector(Sort sort, FieldValueHitQueue<Entry> queue, int numHits, boolean fillFields,
  2. boolean trackDocScores, boolean trackMaxScore, boolean trackTotalHits) {
  3. super(queue, numHits, fillFields, sort.needsScores() || trackDocScores || trackMaxScore);
  4. this.sort = sort;
  5. this.queue = queue;
  6. if (trackMaxScore) {
  7. maxScore = Float.NEGATIVE_INFINITY; // otherwise we would keep NaN
  8. }
  9. this.trackDocScores = trackDocScores;
  10. this.trackMaxScore = trackMaxScore;
  11. // If one of the sort fields needs scores, and if we also track scores, then
  12. // we might call scorer.score() several times per doc so wrapping the scorer
  13. // to cache scores would help
  14. this.mayNeedScoresTwice = sort.needsScores() && (trackDocScores || trackMaxScore);
  15. this.trackTotalHits = trackTotalHits;
  16. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. /** Creates a new Sorter to sort the index with {@code sort} */
  2. Sorter(Sort sort) {
  3. if (sort.needsScores()) {
  4. throw new IllegalArgumentException("Cannot sort an index with a Sort that refers to the relevance score");
  5. }
  6. this.sort = sort;
  7. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. public PagingFieldCollector(Sort sort, FieldValueHitQueue<Entry> queue, FieldDoc after, int numHits, boolean fillFields,
  2. boolean trackDocScores, boolean trackMaxScore, boolean trackTotalHits) {
  3. super(queue, numHits, fillFields, trackDocScores || trackMaxScore || sort.needsScores());
  4. this.sort = sort;
  5. this.queue = queue;
  6. this.trackDocScores = trackDocScores;
  7. this.trackMaxScore = trackMaxScore;
  8. this.after = after;
  9. this.mayNeedScoresTwice = sort.needsScores() && (trackDocScores || trackMaxScore);
  10. this.trackTotalHits = trackTotalHits;
  11. // Must set maxScore to NEG_INF, or otherwise Math.max always returns NaN.
  12. if (trackMaxScore) {
  13. maxScore = Float.NEGATIVE_INFINITY;
  14. }
  15. FieldComparator<?>[] comparators = queue.comparators;
  16. // Tell all comparators their top value:
  17. for(int i=0;i<comparators.length;i++) {
  18. @SuppressWarnings("unchecked")
  19. FieldComparator<Object> comparator = (FieldComparator<Object>) comparators[i];
  20. comparator.setTopValue(after.fields[i]);
  21. }
  22. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public boolean needsScores() {
  3. SortAndFormats sort = subSearchContext.sort();
  4. if (sort != null) {
  5. return sort.sort.needsScores() || subSearchContext.trackScores();
  6. } else {
  7. // sort by score
  8. return true;
  9. }
  10. }

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. protected Weight createInnerHitQueryWeight() throws IOException {
  2. final boolean needsScores = size() != 0 && (sort() == null || sort().sort.needsScores());
  3. return context.searcher().createNormalizedWeight(query(), needsScores);
  4. }

代码示例来源:origin: harbby/presto-connectors

  1. @Override
  2. public boolean needsScores() {
  3. return sortWithinGroup.needsScores();
  4. }
  5. }

代码示例来源:origin: org.apache.lucene/lucene-grouping

  1. @Override
  2. public boolean needsScores() {
  3. return sort.needsScores();
  4. }

代码示例来源:origin: org.infinispan/infinispan-embedded-query

  1. public SimpleFieldCollector(Sort sort, FieldValueHitQueue<Entry> queue, int numHits, boolean fillFields,
  2. boolean trackDocScores, boolean trackMaxScore) {
  3. super(queue, numHits, fillFields, sort.needsScores() || trackDocScores || trackMaxScore);
  4. this.queue = queue;
  5. if (trackMaxScore) {
  6. maxScore = Float.NEGATIVE_INFINITY; // otherwise we would keep NaN
  7. }
  8. this.trackDocScores = trackDocScores;
  9. this.trackMaxScore = trackMaxScore;
  10. // If one of the sort fields needs scores, and if we also track scores, then
  11. // we might call scorer.score() several times per doc so wrapping the scorer
  12. // to cache scores would help
  13. this.mayNeedScoresTwice = sort.needsScores() && (trackDocScores || trackMaxScore);
  14. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

  1. /** Creates a new Sorter to sort the index with {@code sort} */
  2. Sorter(Sort sort) {
  3. if (sort.needsScores()) {
  4. throw new IllegalArgumentException("Cannot sort an index with a Sort that refers to the relevance score");
  5. }
  6. this.sort = sort;
  7. }

代码示例来源:origin: org.infinispan/infinispan-embedded-query

  1. /** Creates a new Sorter to sort the index with {@code sort} */
  2. Sorter(Sort sort) {
  3. if (sort.needsScores()) {
  4. throw new IllegalArgumentException("Cannot sort an index with a Sort that refers to the relevance score");
  5. }
  6. this.sort = sort;
  7. }

代码示例来源:origin: harbby/presto-connectors

  1. /** Creates a new Sorter to sort the index with {@code sort} */
  2. Sorter(Sort sort) {
  3. if (sort.needsScores()) {
  4. throw new IllegalArgumentException("Cannot sort an index with a Sort that refers to the relevance score");
  5. }
  6. this.sort = sort;
  7. }

代码示例来源:origin: harbby/presto-connectors

  1. public SearchGroupDocs(GROUP_VALUE_TYPE groupValue, TopDocsCollector<?> collector) {
  2. this.groupValue = groupValue;
  3. this.collector = collector;
  4. }
  5. }

代码示例来源:origin: org.apache.lucene/lucene-grouping

  1. TopDocsReducer(Sort withinGroupSort,
  2. int maxDocsPerGroup, boolean getScores, boolean getMaxScores, boolean fillSortFields) {
  3. this.needsScores = getScores || getMaxScores || withinGroupSort.needsScores();
  4. this.supplier = withinGroupSort == Sort.RELEVANCE ?
  5. () -> TopScoreDocCollector.create(maxDocsPerGroup) :
  6. () -> TopFieldCollector.create(withinGroupSort, maxDocsPerGroup, fillSortFields, getScores, getMaxScores, true); // TODO: disable exact counts?
  7. }

代码示例来源:origin: harbby/presto-connectors

  1. @Override
  2. public boolean needsScores() {
  3. Sort sort = subSearchContext.sort();
  4. if (sort != null) {
  5. return sort.needsScores() || subSearchContext.trackScores();
  6. } else {
  7. // sort by score
  8. return true;
  9. }
  10. }

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

  1. @Override
  2. public boolean needsScores() {
  3. SortAndFormats sort = subSearchContext.sort();
  4. if (sort != null) {
  5. return sort.sort.needsScores() || subSearchContext.trackScores();
  6. } else {
  7. // sort by score
  8. return true;
  9. }
  10. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. @Override
  2. public boolean needsScores() {
  3. SortAndFormats sort = subSearchContext.sort();
  4. if (sort != null) {
  5. return sort.sort.needsScores() || subSearchContext.trackScores();
  6. } else {
  7. // sort by score
  8. return true;
  9. }
  10. }

代码示例来源:origin: apache/servicemix-bundles

  1. @Override
  2. public boolean needsScores() {
  3. SortAndFormats sort = subSearchContext.sort();
  4. if (sort != null) {
  5. return sort.sort.needsScores() || subSearchContext.trackScores();
  6. } else {
  7. // sort by score
  8. return true;
  9. }
  10. }

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

  1. protected Weight createInnerHitQueryWeight() throws IOException {
  2. final boolean needsScores = size() != 0 && (sort() == null || sort().sort.needsScores());
  3. return context.searcher().createNormalizedWeight(query(), needsScores);
  4. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  1. protected Weight createInnerHitQueryWeight() throws IOException {
  2. final boolean needsScores = size() != 0 && (sort() == null || sort().sort.needsScores());
  3. return context.searcher().createNormalizedWeight(query(), needsScores);
  4. }

代码示例来源:origin: apache/servicemix-bundles

  1. protected Weight createInnerHitQueryWeight() throws IOException {
  2. final boolean needsScores = size() != 0 && (sort() == null || sort().sort.needsScores());
  3. return context.searcher().createNormalizedWeight(query(), needsScores);
  4. }

相关文章