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

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

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

Sort.toString介绍

暂无

代码示例

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

  1. /**
  2. * Returns the identifier of this {@link Sorter}.
  3. * <p>This identifier is similar to {@link Object#hashCode()} and should be
  4. * chosen so that two instances of this class that sort documents likewise
  5. * will have the same identifier. On the contrary, this identifier should be
  6. * different on different {@link Sort sorts}.
  7. */
  8. public String getID() {
  9. return sort.toString();
  10. }

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

  1. @Override
  2. public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException {
  3. TopDocs oneHit = new TopDocs(1, new ScoreDoc[] {new ScoreDoc(docID, firstPassExplanation.getValue())});
  4. TopDocs hits = rescore(searcher, oneHit, 1);
  5. assert hits.totalHits == 1;
  6. List<Explanation> subs = new ArrayList<>();
  7. // Add first pass:
  8. Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation);
  9. subs.add(first);
  10. FieldDoc fieldDoc = (FieldDoc) hits.scoreDocs[0];
  11. // Add sort values:
  12. SortField[] sortFields = sort.getSort();
  13. for(int i=0;i<sortFields.length;i++) {
  14. subs.add(Explanation.match(0.0f, "sort field " + sortFields[i].toString() + " value=" + fieldDoc.fields[i]));
  15. }
  16. // TODO: if we could ask the Sort to explain itself then
  17. // we wouldn't need the separate ExpressionRescorer...
  18. return Explanation.match(0.0f, "sort field values for sort=" + sort.toString(), subs);
  19. }
  20. }

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

  1. /**
  2. * Returns the identifier of this {@link Sorter}.
  3. * <p>This identifier is similar to {@link Object#hashCode()} and should be
  4. * chosen so that two instances of this class that sort documents likewise
  5. * will have the same identifier. On the contrary, this identifier should be
  6. * different on different {@link Sort sorts}.
  7. */
  8. public String getID() {
  9. return sort.toString();
  10. }

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

  1. /**
  2. * Returns the identifier of this {@link Sorter}.
  3. * <p>This identifier is similar to {@link Object#hashCode()} and should be
  4. * chosen so that two instances of this class that sort documents likewise
  5. * will have the same identifier. On the contrary, this identifier should be
  6. * different on different {@link Sort sorts}.
  7. */
  8. public String getID() {
  9. return sort.toString();
  10. }

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

  1. /**
  2. * Returns the identifier of this {@link Sorter}.
  3. * <p>This identifier is similar to {@link Object#hashCode()} and should be
  4. * chosen so that two instances of this class that sort documents likewise
  5. * will have the same identifier. On the contrary, this identifier should be
  6. * different on different {@link Sort sorts}.
  7. */
  8. public String getID() {
  9. return sort.toString();
  10. }

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

  1. /** Returns {@code true} if the given {@code reader} is sorted by the
  2. * {@code sort} given. Typically the given {@code sort} would be the
  3. * {@link SortingMergePolicy#getSort()} order of a {@link SortingMergePolicy}. */
  4. public static boolean isSorted(LeafReader reader, Sort sort) {
  5. String description = getSortDescription(reader);
  6. if (description != null && description.equals(sort.toString())) {
  7. return true;
  8. }
  9. return false;
  10. }

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

  1. /** Returns {@code true} if the given {@code reader} is sorted by the
  2. * {@code sort} given. Typically the given {@code sort} would be the
  3. * {@link SortingMergePolicy#getSort()} order of a {@link SortingMergePolicy}. */
  4. public static boolean isSorted(LeafReader reader, Sort sort) {
  5. String description = getSortDescription(reader);
  6. if (description != null && description.equals(sort.toString())) {
  7. return true;
  8. }
  9. return false;
  10. }

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

  1. @Override
  2. public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException {
  3. TopDocs oneHit = new TopDocs(1, new ScoreDoc[] {new ScoreDoc(docID, firstPassExplanation.getValue())});
  4. TopDocs hits = rescore(searcher, oneHit, 1);
  5. assert hits.totalHits == 1;
  6. List<Explanation> subs = new ArrayList<>();
  7. // Add first pass:
  8. Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation);
  9. subs.add(first);
  10. FieldDoc fieldDoc = (FieldDoc) hits.scoreDocs[0];
  11. // Add sort values:
  12. SortField[] sortFields = sort.getSort();
  13. for(int i=0;i<sortFields.length;i++) {
  14. subs.add(Explanation.match(0.0f, "sort field " + sortFields[i].toString() + " value=" + fieldDoc.fields[i]));
  15. }
  16. // TODO: if we could ask the Sort to explain itself then
  17. // we wouldn't need the separate ExpressionRescorer...
  18. return Explanation.match(0.0f, "sort field values for sort=" + sort.toString(), subs);
  19. }
  20. }

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

  1. @Override
  2. public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException {
  3. TopDocs oneHit = new TopDocs(1, new ScoreDoc[] {new ScoreDoc(docID, firstPassExplanation.getValue())});
  4. TopDocs hits = rescore(searcher, oneHit, 1);
  5. assert hits.totalHits == 1;
  6. List<Explanation> subs = new ArrayList<>();
  7. // Add first pass:
  8. Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation);
  9. subs.add(first);
  10. FieldDoc fieldDoc = (FieldDoc) hits.scoreDocs[0];
  11. // Add sort values:
  12. SortField[] sortFields = sort.getSort();
  13. for(int i=0;i<sortFields.length;i++) {
  14. subs.add(Explanation.match(0.0f, "sort field " + sortFields[i].toString() + " value=" + fieldDoc.fields[i]));
  15. }
  16. // TODO: if we could ask the Sort to explain itself then
  17. // we wouldn't need the separate ExpressionRescorer...
  18. return Explanation.match(0.0f, "sort field values for sort=" + sort.toString(), subs);
  19. }
  20. }

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

  1. @Override
  2. public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException {
  3. TopDocs oneHit = new TopDocs(1, new ScoreDoc[] {new ScoreDoc(docID, firstPassExplanation.getValue())});
  4. TopDocs hits = rescore(searcher, oneHit, 1);
  5. assert hits.totalHits == 1;
  6. List<Explanation> subs = new ArrayList<>();
  7. // Add first pass:
  8. Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation);
  9. subs.add(first);
  10. FieldDoc fieldDoc = (FieldDoc) hits.scoreDocs[0];
  11. // Add sort values:
  12. SortField[] sortFields = sort.getSort();
  13. for(int i=0;i<sortFields.length;i++) {
  14. subs.add(Explanation.match(0.0f, "sort field " + sortFields[i].toString() + " value=" + fieldDoc.fields[i]));
  15. }
  16. // TODO: if we could ask the Sort to explain itself then
  17. // we wouldn't need the separate ExpressionRescorer...
  18. return Explanation.match(0.0f, "sort field values for sort=" + sort.toString(), subs);
  19. }
  20. }

相关文章