jpountz commented on a change in pull request #680: LUCENE-8803: Provide a FieldComparator to allow sorting by a feature from a FeatureField URL: https://github.com/apache/lucene-solr/pull/680#discussion_r286102178
########## File path: lucene/core/src/java/org/apache/lucene/document/FeatureField.java ########## @@ -518,4 +521,22 @@ static float computePivotFeatureValue(IndexReader reader, String featureField, S float avgFreq = (float) ((double) states.totalTermFreq() / states.docFreq()); return decodeFeatureValue(avgFreq); } + + /** + * Creates a SortField for sorting by the value of a feature. + * <p> + * This sort orders documents by descending value of a feature. The value returned in {@link FieldDoc} for + * the hits contains a Float instance with the feature value. + * <p> + * If a document is missing the field, then it is treated as having a vaue of <code>0.0f</code>. + * <p> + * + * @param field field name. Must not be null. + * @param featureName feature name. Must not be null. + * @return SortField ordering documents by the value of the feature + * @throws IllegalArgumentException if {@code field} or {@code featureName} is null. + */ + public static SortField newFeatureSort(String field, BytesRef featureName) { Review comment: can it take a String featureName like the query? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org