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

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

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

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

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

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

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

  1. if (segmentSort.equals(indexSort) == false) {
  2. 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

代码示例来源: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. /**
  2. * Create a new AllGroupHeadsCollector based on the type of within-group Sort required
  3. * @param selector a GroupSelector to define the groups
  4. * @param sort the within-group sort to use to choose the group head document
  5. * @param <T> the group value type
  6. */
  7. public static <T> AllGroupHeadsCollector<T> newCollector(GroupSelector<T> selector, Sort sort) {
  8. if (sort.equals(Sort.RELEVANCE))
  9. return new ScoringGroupHeadsCollector<>(selector, sort);
  10. return new SortingGroupHeadsCollector<>(selector, sort);
  11. }

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

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

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

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

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

  1. if (segmentSort.equals(indexSort) == false) {
  2. 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

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

相关文章