See the {@link #create(LLTempLMDBEnv, Sort, int, int)} (org.apache.lucene.search.Sort, int, int)} method for instantiating a
* TopFieldCollector.
*
+ * This class must mirror this changes:
+ *
+ * Lucene TopFieldCollector changes on GitHub
*/
public abstract class LMDBFullFieldDocCollector
extends FullDocsCollector NOTE: The values {@link Float#NaN} and {@link Float#NEGATIVE_INFINITY} are not valid
* scores. This collector will not properly collect hits with such scores.
+ *
+ * This class must mirror this changes:
+ *
+ * Lucene TopScoreDocCollector changes on GitHub
*/
public abstract class LMDBFullScoreDocCollector extends FullDocsCollector Parameter {@code field} provided in the constructor is used as a field name in the default
+ * implementations of the methods {@code getNumericDocValues} and {@code getPointValues} to retrieve
+ * doc values and points. You can pass a dummy value for a field name (e.g. when sorting by script),
+ * but in this case you must override both of these methods.
+ *
+ * Based on {@link org.apache.lucene.search.comparators.NumericComparator}
*/
public abstract class NumericComparator If you override this method, you must also override {@link
+ * #getPointValues(LeafReaderContext, String)} This class uses sort optimization that leverages
+ * points to filter out non-competitive matches, which relies on the assumption that points and
+ * doc values record the same information.
+ *
+ * @param context – reader context
+ * @param field - field name
+ * @return numeric doc values for the field in this segment.
+ * @throws IOException If there is a low-level I/O error
+ */
+ protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field)
throws IOException {
return DocValues.getNumeric(context.reader(), field);
}
+ /**
+ * Retrieves point values for the field in this segment
+ *
+ * If you override this method, you must also override {@link
+ * #getNumericDocValues(LeafReaderContext, String)} This class uses sort optimization that
+ * leverages points to filter out non-competitive matches, which relies on the assumption that
+ * points and doc values record the same information. Return {@code null} even if no points
+ * implementation is available, in this case sort optimization with points will be disabled.
+ *
+ * @param context – reader context
+ * @param field - field name
+ * @return point values for the field in this segment if they are available or {@code null} if
+ * sort optimization with points should be disabled.
+ * @throws IOException If there is a low-level I/O error
+ */
+ protected PointValues getPointValues(LeafReaderContext context, String field)
+ throws IOException {
+ return context.reader().getPointValues(field);
+ }
+
@Override
public void setBottom(int slot) throws IOException {
queueFull = true; // if we are setting bottom, it means that we have collected enough hits
diff --git a/src/main/java/it/cavallium/dbengine/lucene/comparators/RelevanceComparator.java b/src/main/java/it/cavallium/dbengine/lucene/comparators/RelevanceComparator.java
index 11414b3..743f768 100644
--- a/src/main/java/it/cavallium/dbengine/lucene/comparators/RelevanceComparator.java
+++ b/src/main/java/it/cavallium/dbengine/lucene/comparators/RelevanceComparator.java
@@ -38,6 +38,7 @@ import org.apache.lucene.util.BytesRefBuilder;
* Sorts by descending relevance. NOTE: if you are sorting only by descending relevance and then secondarily by
* ascending docID, performance is faster using {@link org.apache.lucene.search.TopScoreDocCollector} directly (which {@link
* org.apache.lucene.search.IndexSearcher#search(Query, int)} uses when no {@link org.apache.lucene.search.Sort} is specified).
+ * Based on {@link org.apache.lucene.search.FieldComparator.RelevanceComparator}
*/
public final class RelevanceComparator extends FieldComparator