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 thevalidate()
function, and must implement theparamsToMap()
and createWeight() methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Feature.FeatureWeight
Weight for a feature
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Feature.FeatureWeight
createWeight(org.apache.lucene.search.IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, org.apache.lucene.search.Query originalQuery, Map<String,String[]> efi)
protected LinkedHashMap<String,Object>
defaultParamsToMap()
boolean
equals(Object o)
float
getDefaultValue()
int
getIndex()
static Feature
getInstance(SolrResourceLoader solrResourceLoader, String className, String name, Map<String,Object> params)
String
getName()
int
hashCode()
abstract LinkedHashMap<String,Object>
paramsToMap()
long
ramBytesUsed()
void
setDefaultValue(Object obj)
void
setIndex(int index)
String
toString(String field)
protected abstract void
validate()
As part of creation of a feature instance, this function confirms that the feature parameters are valid.void
visit(org.apache.lucene.search.QueryVisitor visitor)
-
Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, rewrite, sameClassAs, toString
-
-
-
-
Field Detail
-
name
protected final String name
-
-
Method Detail
-
getInstance
public static Feature getInstance(SolrResourceLoader solrResourceLoader, String className, String name, Map<String,Object> params)
-
validate
protected abstract void validate() throws FeatureException
As part of creation of a feature instance, this function confirms that the feature parameters are valid.- Throws:
FeatureException
- Feature Exception
-
toString
public String toString(String field)
- Specified by:
toString
in 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
public void setDefaultValue(Object obj)
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classorg.apache.lucene.search.Query
-
equals
public boolean equals(Object o)
- Specified by:
equals
in classorg.apache.lucene.search.Query
-
ramBytesUsed
public long ramBytesUsed()
- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-
visit
public void visit(org.apache.lucene.search.QueryVisitor visitor)
- Specified by:
visit
in classorg.apache.lucene.search.Query
-
getName
public String 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
public abstract LinkedHashMap<String,Object> paramsToMap()
-
defaultParamsToMap
protected LinkedHashMap<String,Object> defaultParamsToMap()
-
-