Package org.apache.lucene.document
Class FeatureSortField
- java.lang.Object
-
- org.apache.lucene.search.SortField
-
- org.apache.lucene.document.FeatureSortField
-
final class FeatureSortField extends SortField
Sorts using the value of a specified feature name from aFeatureField
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
FeatureSortField.FeatureComparator
Parses a feature field's values as float and sorts by descending value-
Nested classes/interfaces inherited from class org.apache.lucene.search.SortField
SortField.Provider, SortField.Type
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
featureName
-
Fields inherited from class org.apache.lucene.search.SortField
FIELD_DOC, FIELD_SCORE, missingValue, STRING_FIRST, STRING_LAST
-
-
Constructor Summary
Constructors Constructor Description FeatureSortField(java.lang.String field, java.lang.String featureName)
Creates aFeatureSortField
that can be used to sort hits by the value of a particular feature in aFeatureField
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Returns true ifo
is equal to this.FieldComparator<?>
getComparator(int numHits, int sortPos)
Returns theFieldComparator
to use for sorting.int
hashCode()
Returns a hash code for thisSortField
instance.void
setMissingValue(java.lang.Object missingValue)
Set the value to use for documents that don't have a value.java.lang.String
toString()
-
Methods inherited from class org.apache.lucene.search.SortField
getBytesComparator, getComparatorSource, getField, getIndexSorter, getMissingValue, getReverse, getType, needsScores, readType, rewrite, setBytesComparator
-
-
-
-
Constructor Detail
-
FeatureSortField
public FeatureSortField(java.lang.String field, java.lang.String featureName)
Creates aFeatureSortField
that can be used to sort hits by the value of a particular feature in aFeatureField
.- Parameters:
featureName
- The name of the feature to use for the sort value
-
-
Method Detail
-
getComparator
public FieldComparator<?> getComparator(int numHits, int sortPos)
Description copied from class:SortField
Returns theFieldComparator
to use for sorting.- Overrides:
getComparator
in classSortField
- Parameters:
numHits
- number of top hits the queue will storesortPos
- position of this SortField withinSort
. The comparator is primary if sortPos==0, secondary if sortPos==1, etc. Some comparators can optimize themselves when they are the primary sort.- Returns:
FieldComparator
to use when sorting
-
setMissingValue
public void setMissingValue(java.lang.Object missingValue)
Description copied from class:SortField
Set the value to use for documents that don't have a value.- Overrides:
setMissingValue
in classSortField
-
hashCode
public int hashCode()
Description copied from class:SortField
Returns a hash code for thisSortField
instance. If aFieldComparatorSource
was provided, it must properly implement hashCode (unless a singleton is always used).
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:SortField
Returns true ifo
is equal to this. If aFieldComparatorSource
was provided, it must properly implement equals (unless a singleton is always used).
-
-