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
 
 
 
- 
 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 SummaryNested Classes Modifier and Type Class Description classValueFeature.ValueFeatureWeight- 
Nested classes/interfaces inherited from class org.apache.solr.ltr.feature.FeatureFeature.FeatureWeight
 
- 
 - 
Constructor SummaryConstructors Constructor Description ValueFeature(String name, Map<String,Object> params)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Feature.FeatureWeightcreateWeight(org.apache.lucene.search.IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, org.apache.lucene.search.Query originalQuery, Map<String,String[]> efi)ObjectgetValue()booleanisRequired()LinkedHashMap<String,Object>paramsToMap()voidsetRequired(boolean required)voidsetValue(Object value)protected voidvalidate()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.Featureequals, getDefaultValue, getIndex, getInstance, getName, hashCode, setDefaultValue, setIndex, toString
 
- 
 
- 
- 
- 
Method Detail- 
getValuepublic Object getValue() 
 - 
setValuepublic void setValue(Object value) 
 - 
isRequiredpublic boolean isRequired() 
 - 
setRequiredpublic void setRequired(boolean required) 
 - 
paramsToMappublic LinkedHashMap<String,Object> paramsToMap() - Specified by:
- paramsToMapin class- Feature
 
 - 
validateprotected void validate() throws FeatureExceptionDescription copied from class:FeatureAs part of creation of a feature instance, this function confirms that the feature parameters are valid.- Specified by:
- validatein class- Feature
- Throws:
- FeatureException- Feature Exception
 
 - 
createWeightpublic 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:
- createWeightin class- Feature
- Throws:
- IOException
 
 
- 
 
-