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

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

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

Sort.equals介绍

[英]Returns true if o is equal to this.
[中]如果o等于此值,则返回true。

代码示例

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

/** Confirms that the incoming index sort (if any) matches the existing index sort (if any).
 *  This is unfortunately just best effort, because it could be the old index only has unsorted flushed segments built
 *  before {@link Version#LUCENE_6_5_0} (flushed segments are sorted in Lucene 7.0).  */
private void validateIndexSort() throws CorruptIndexException {
 Sort indexSort = config.getIndexSort();
 if (indexSort != null) {
  for(SegmentCommitInfo info : segmentInfos) {
   Sort segmentIndexSort = info.info.getIndexSort();
   if (segmentIndexSort != null && indexSort.equals(segmentIndexSort) == false) {
    throw new IllegalArgumentException("cannot change previous indexSort=" + segmentIndexSort + " (from segment=" + info + ") to new indexSort=" + indexSort);
   } else if (segmentIndexSort == null && info.info.getVersion().onOrAfter(Version.LUCENE_6_5_0)) {
    // Flushed segments are not sorted if they were built with a version prior to 6.5.0
    throw new CorruptIndexException("segment not sorted with indexSort=" + segmentIndexSort, info.info.toString());
   }
  }
 }
}

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

private void validateMergeReader(CodecReader leaf) {
 LeafMetaData segmentMeta = leaf.getMetaData();
 if (segmentInfos.getIndexCreatedVersionMajor() != segmentMeta.getCreatedVersionMajor()) {
  throw new IllegalArgumentException("Cannot merge a segment that has been created with major version "
    + segmentMeta.getCreatedVersionMajor() + " into this index which has been created by major version "
    + segmentInfos.getIndexCreatedVersionMajor());
 }
 if (segmentInfos.getIndexCreatedVersionMajor() >= 7 && segmentMeta.getMinVersion() == null) {
  throw new IllegalStateException("Indexes created on or after Lucene 7 must record the created version major, but " + leaf + " hides it");
 }
 Sort leafIndexSort = segmentMeta.getSort();
 if (config.getIndexSort() != null && leafIndexSort != null
   && config.getIndexSort().equals(leafIndexSort) == false) {
  throw new IllegalArgumentException("cannot change index sort from " + leafIndexSort + " to " + config.getIndexSort());
 }
}

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

if (segmentSort.equals(indexSort) == false) {
 throw new IllegalArgumentException("index sort mismatch: merged segment has sort=" + indexSort + " but to-be-merged segment has sort=" + segmentSort);

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

if (indexSort == null) {
 indexSort = leafIndexSort;
} else if (leafIndexSort != null && indexSort.equals(leafIndexSort) == false) {
 throw new IllegalArgumentException("cannot combine LeafReaders that have different index sorts: saw both sort=" + indexSort + " and " + leafIndexSort);

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

private boolean equalsTo(SearchAfterSortedDocQuery other) {
  return sort.equals(other.sort) &&
    after.doc == other.after.doc &&
    Double.compare(after.score, other.after.score) == 0 &&
    Arrays.equals(after.fields, other.after.fields);
}

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

/**
 * Returns true if the provided <code>query</code> returns docs in index order (internal doc ids).
 * @param query The query to execute
 * @param sf The query sort
 */
static boolean returnsDocsInOrder(Query query, SortAndFormats sf) {
  if (sf == null || Sort.RELEVANCE.equals(sf.sort)) {
    // sort by score
    // queries that return constant scores will return docs in index
    // order since Lucene tie-breaks on the doc id
    return query.getClass() == ConstantScoreQuery.class
      || query.getClass() == MatchAllDocsQuery.class;
  } else {
    return Sort.INDEXORDER.equals(sf.sort);
  }
}

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

msg(infoStream, "    sort=" + indexSort);
if (previousIndexSort != null) {
 if (previousIndexSort.equals(indexSort) == false) {
  throw new RuntimeException("index sort changed from " + previousIndexSort + " to " + indexSort);

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

if (indexSort != null && segmentIndexSort != null && indexSort.equals(segmentIndexSort) == false) {

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

private static boolean returnsDocsInOrder(Query query, SortAndFormats sf) {
  if (sf == null || Sort.RELEVANCE.equals(sf.sort)) {
    // sort by score
    // queries that return constant scores will return docs in index
    // order since Lucene tie-breaks on the doc id
    return query.getClass() == ConstantScoreQuery.class
        || query.getClass() == MatchAllDocsQuery.class;
  } else {
    return Sort.INDEXORDER.equals(sf.sort);
  }
}

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

private static boolean returnsDocsInOrder(Query query, Sort sort) {
  if (sort == null || Sort.RELEVANCE.equals(sort)) {
    // sort by score
    // queries that return constant scores will return docs in index
    // order since Lucene tie-breaks on the doc id
    return query.getClass() == ConstantScoreQuery.class
        || query.getClass() == MatchAllDocsQuery.class;
  } else {
    return Sort.INDEXORDER.equals(sort);
  }
}

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

/**
 * Returns true if the provided <code>query</code> returns docs in index order (internal doc ids).
 * @param query The query to execute
 * @param sf The query sort
 */
static boolean returnsDocsInOrder(Query query, SortAndFormats sf) {
  if (sf == null || Sort.RELEVANCE.equals(sf.sort)) {
    // sort by score
    // queries that return constant scores will return docs in index
    // order since Lucene tie-breaks on the doc id
    return query.getClass() == ConstantScoreQuery.class
      || query.getClass() == MatchAllDocsQuery.class;
  } else {
    return Sort.INDEXORDER.equals(sf.sort);
  }
}

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

private boolean equalsTo(SearchAfterSortedDocQuery other) {
  return sort.equals(other.sort) &&
    after.doc == other.after.doc &&
    Double.compare(after.score, other.after.score) == 0 &&
    Arrays.equals(after.fields, other.after.fields);
}

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

private boolean equalsTo(SearchAfterSortedDocQuery other) {
  return sort.equals(other.sort) &&
    after.doc == other.after.doc &&
    Double.compare(after.score, other.after.score) == 0 &&
    Arrays.equals(after.fields, other.after.fields);
}

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

/**
 * Returns true if the provided <code>query</code> returns docs in index order (internal doc ids).
 * @param query The query to execute
 * @param sf The query sort
 */
static boolean returnsDocsInOrder(Query query, SortAndFormats sf) {
  if (sf == null || Sort.RELEVANCE.equals(sf.sort)) {
    // sort by score
    // queries that return constant scores will return docs in index
    // order since Lucene tie-breaks on the doc id
    return query.getClass() == ConstantScoreQuery.class
      || query.getClass() == MatchAllDocsQuery.class;
  } else {
    return Sort.INDEXORDER.equals(sf.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

/**
 * Create a new AllGroupHeadsCollector based on the type of within-group Sort required
 * @param selector a GroupSelector to define the groups
 * @param sort     the within-group sort to use to choose the group head document
 * @param <T>      the group value type
 */
public static <T> AllGroupHeadsCollector<T> newCollector(GroupSelector<T> selector, Sort sort) {
 if (sort.equals(Sort.RELEVANCE))
  return new ScoringGroupHeadsCollector<>(selector, sort);
 return new SortingGroupHeadsCollector<>(selector, sort);
}

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

/** Confirms that the incoming index sort (if any) matches the existing index sort (if any).
 *  This is unfortunately just best effort, because it could be the old index only has unsorted flushed segments built
 *  before {@link Version#LUCENE_6_5_0} (flushed segments are sorted in Lucene 7.0).  */
private void validateIndexSort() throws CorruptIndexException {
 Sort indexSort = config.getIndexSort();
 if (indexSort != null) {
  for(SegmentCommitInfo info : segmentInfos) {
   Sort segmentIndexSort = info.info.getIndexSort();
   if (segmentIndexSort != null && indexSort.equals(segmentIndexSort) == false) {
    throw new IllegalArgumentException("cannot change previous indexSort=" + segmentIndexSort + " (from segment=" + info + ") to new indexSort=" + indexSort);
   } else if (segmentIndexSort == null && info.info.getVersion().onOrAfter(Version.LUCENE_6_5_0)) {
    // Flushed segments are not sorted if they were built with a version prior to 6.5.0
    throw new CorruptIndexException("segment not sorted with indexSort=" + segmentIndexSort, info.info.toString());
   }
  }
 }
}

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

private void validateMergeReader(CodecReader leaf) {
 LeafMetaData segmentMeta = leaf.getMetaData();
 if (segmentInfos.getIndexCreatedVersionMajor() != segmentMeta.getCreatedVersionMajor()) {
  throw new IllegalArgumentException("Cannot merge a segment that has been created with major version "
    + segmentMeta.getCreatedVersionMajor() + " into this index which has been created by major version "
    + segmentInfos.getIndexCreatedVersionMajor());
 }
 if (segmentInfos.getIndexCreatedVersionMajor() >= 7 && segmentMeta.getMinVersion() == null) {
  throw new IllegalStateException("Indexes created on or after Lucene 7 must record the created version major, but " + leaf + " hides it");
 }
 Sort leafIndexSort = segmentMeta.getSort();
 if (config.getIndexSort() != null && leafIndexSort != null
   && config.getIndexSort().equals(leafIndexSort) == false) {
  throw new IllegalArgumentException("cannot change index sort from " + leafIndexSort + " to " + config.getIndexSort());
 }
}

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

if (segmentSort.equals(indexSort) == false) {
 throw new IllegalArgumentException("index sort mismatch: merged segment has sort=" + indexSort + " but to-be-merged segment has sort=" + segmentSort);

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

if (withinGroupSort.equals(Sort.RELEVANCE)) {

相关文章