Package org.apache.solr.ltr.feature
Class ValueFeature
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.solr.ltr.feature.Feature
-
- org.apache.solr.ltr.feature.ValueFeature
-
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
public class ValueFeature extends Feature
This feature allows to return a constant given value for the current document.Example configuration:
{ "name" : "userFromMobile", "class" : "org.apache.solr.ltr.feature.ValueFeature", "params" : { "value" : "${userFromMobile}", "required":true } }
You can place a constant value like "1.3f" in the value params, but many times you would want to pass in external information to use per request. For instance, maybe you want to rank things differently if the search came from a mobile device, or maybe you want to use your external query intent system as a feature. In the rerank request you can pass in rq={... efi.userFromMobile=1}, and the above feature will return 1 for all the docs for that request. If required is set to true, the request will return an error since you failed to pass in the efi, otherwise if will just skip the feature and use a default value of 0 instead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ValueFeature.ValueFeatureWeight
-
Nested classes/interfaces inherited from class org.apache.solr.ltr.feature.Feature
Feature.FeatureWeight
-
-
Constructor Summary
Constructors Constructor Description ValueFeature(String name, Map<String,Object> params)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Feature.FeatureWeight
createWeight(org.apache.lucene.search.IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, org.apache.lucene.search.Query originalQuery, Map<String,String[]> efi)
Object
getValue()
boolean
isRequired()
LinkedHashMap<String,Object>
paramsToMap()
void
setRequired(boolean required)
void
setValue(Object value)
protected void
validate()
As part of creation of a feature instance, this function confirms that the feature parameters are valid.-
Methods inherited from class org.apache.solr.ltr.feature.Feature
defaultParamsToMap, equals, getDefaultValue, getIndex, getInstance, getName, hashCode, ramBytesUsed, setDefaultValue, setIndex, toString, visit
-
Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, rewrite, sameClassAs, toString
-
-
-
-
Method Detail
-
getValue
public Object getValue()
-
setValue
public void setValue(Object value)
-
isRequired
public boolean isRequired()
-
setRequired
public void setRequired(boolean required)
-
paramsToMap
public LinkedHashMap<String,Object> paramsToMap()
- Specified by:
paramsToMap
in classFeature
-
validate
protected void validate() throws FeatureException
Description copied from class:Feature
As part of creation of a feature instance, this function confirms that the feature parameters are valid.- Specified by:
validate
in classFeature
- Throws:
FeatureException
- Feature Exception
-
createWeight
public 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
- Specified by:
createWeight
in classFeature
- Throws:
IOException
-
-