Package org.apache.solr.ltr.feature
Class Feature
java.lang.Object
org.apache.lucene.search.Query
org.apache.solr.ltr.feature.Feature
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
- Direct Known Subclasses:
FieldLengthFeature,FieldValueFeature,OriginalScoreFeature,SolrFeature,ValueFeature
public abstract class Feature
extends org.apache.lucene.search.Query
implements org.apache.lucene.util.Accountable
A recipe for computing a feature. Subclass this for specialized feature calculations.
A feature consists of
- a name as the identifier
- parameters to represent the specific feature
Example configuration (snippet):
{
"class" : "...",
"name" : "myFeature",
"params" : {
...
}
}
Feature is an abstract class and concrete classes should implement the validate() function, and must implement the paramsToMap() and createWeight() methods.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Feature.FeatureWeightcreateWeight(org.apache.lucene.search.IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, org.apache.lucene.search.Query originalQuery, Map<String, String[]> efi) protected LinkedHashMap<String, Object> booleanfloatintgetIndex()static FeaturegetInstance(SolrResourceLoader solrResourceLoader, String className, String name, Map<String, Object> params) getName()inthashCode()abstract LinkedHashMap<String, Object> longvoidsetDefaultValue(Object obj) voidsetIndex(int index) protected abstract voidvalidate()As part of creation of a feature instance, this function confirms that the feature parameters are valid.voidvisit(org.apache.lucene.search.QueryVisitor visitor) Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, sameClassAs, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
name
-
-
Constructor Details
-
Feature
-
-
Method Details
-
getInstance
-
validate
As part of creation of a feature instance, this function confirms that the feature parameters are valid.- Throws:
FeatureException- Feature Exception
-
toString
- Specified by:
toStringin classorg.apache.lucene.search.Query
-
createWeight
public abstract Feature.FeatureWeight createWeight(org.apache.lucene.search.IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, org.apache.lucene.search.Query originalQuery, Map<String, String[]> efi) throws IOException- Throws:
IOException
-
getDefaultValue
public float getDefaultValue() -
setDefaultValue
-
hashCode
public int hashCode()- Specified by:
hashCodein classorg.apache.lucene.search.Query
-
equals
- Specified by:
equalsin classorg.apache.lucene.search.Query
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
visit
public void visit(org.apache.lucene.search.QueryVisitor visitor) - Specified by:
visitin classorg.apache.lucene.search.Query
-
getName
- Returns:
- the name
-
getIndex
public int getIndex()- Returns:
- the id
-
setIndex
public void setIndex(int index) - Parameters:
index- Unique ID for this feature. Similar to feature name, except it can be used to directly access the feature in the global list of features.
-
paramsToMap
-
defaultParamsToMap
-