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
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 ClassesNested classes/interfaces inherited from class org.apache.solr.ltr.feature.Feature
Feature.FeatureWeight -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateWeight(org.apache.lucene.search.IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, org.apache.lucene.search.Query originalQuery, Map<String, String[]> efi) getValue()booleanvoidsetRequired(boolean required) voidprotected 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.Feature
defaultParamsToMap, equals, getDefaultValue, getIndex, getInstance, getName, hashCode, ramBytesUsed, setDefaultValue, setIndex, toString, visitMethods 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
-
Constructor Details
-
ValueFeature
-
-
Method Details
-
getValue
-
setValue
-
isRequired
public boolean isRequired() -
setRequired
public void setRequired(boolean required) -
paramsToMap
- Specified by:
paramsToMapin classFeature
-
validate
Description copied from class:FeatureAs part of creation of a feature instance, this function confirms that the feature parameters are valid.- Specified by:
validatein 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:
createWeightin classFeature- Throws:
IOException
-