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

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

本文整理了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

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

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

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

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

public PagingFieldCollector(Sort sort, FieldValueHitQueue<Entry> queue, FieldDoc after, int numHits, boolean fillFields,
              boolean trackDocScores, boolean trackMaxScore, boolean trackTotalHits) {
 super(queue, numHits, fillFields, trackDocScores || trackMaxScore || sort.needsScores());
 this.sort = sort;
 this.queue = queue;
 this.trackDocScores = trackDocScores;
 this.trackMaxScore = trackMaxScore;
 this.after = after;
 this.mayNeedScoresTwice = sort.needsScores() && (trackDocScores || trackMaxScore);
 this.trackTotalHits = trackTotalHits;
 // Must set maxScore to NEG_INF, or otherwise Math.max always returns NaN.
 if (trackMaxScore) {
  maxScore = Float.NEGATIVE_INFINITY;
 }
 FieldComparator<?>[] comparators = queue.comparators;
 // Tell all comparators their top value:
 for(int i=0;i<comparators.length;i++) {
  @SuppressWarnings("unchecked")
  FieldComparator<Object> comparator = (FieldComparator<Object>) comparators[i];
  comparator.setTopValue(after.fields[i]);
 }
}

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

@Override
public boolean needsScores() {
  SortAndFormats sort = subSearchContext.sort();
  if (sort != null) {
    return sort.sort.needsScores() || subSearchContext.trackScores();
  } else {
    // sort by score
    return true;
  }
}

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

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

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

@Override
 public boolean needsScores() {
  return sortWithinGroup.needsScores();
 }
}

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

@Override
public boolean needsScores() {
 return sort.needsScores();
}

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

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

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

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

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

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

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

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

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

public SearchGroupDocs(GROUP_VALUE_TYPE groupValue, TopDocsCollector<?> collector) {
  this.groupValue = groupValue;
  this.collector = collector;
 }
}

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

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

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

@Override
public boolean needsScores() {
  Sort sort = subSearchContext.sort();
  if (sort != null) {
    return sort.needsScores() || subSearchContext.trackScores();
  } else {
    // sort by score
    return true;
  }
}

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

@Override
public boolean needsScores() {
  SortAndFormats sort = subSearchContext.sort();
  if (sort != null) {
    return sort.sort.needsScores() || subSearchContext.trackScores();
  } else {
    // sort by score
    return true;
  }
}

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

@Override
public boolean needsScores() {
  SortAndFormats sort = subSearchContext.sort();
  if (sort != null) {
    return sort.sort.needsScores() || subSearchContext.trackScores();
  } else {
    // sort by score
    return true;
  }
}

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

@Override
public boolean needsScores() {
  SortAndFormats sort = subSearchContext.sort();
  if (sort != null) {
    return sort.sort.needsScores() || subSearchContext.trackScores();
  } else {
    // sort by score
    return true;
  }
}

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

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

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

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

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

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

相关文章