public class ValueFeature extends Feature
{ "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.
Modifier and Type | Class and Description |
---|---|
class |
ValueFeature.ValueFeatureWeight |
Feature.FeatureWeight
NULL_ACCOUNTABLE
Constructor and Description |
---|
ValueFeature(String name,
Map<String,Object> params) |
Modifier and Type | Method and Description |
---|---|
Feature.FeatureWeight |
createWeight(IndexSearcher searcher,
boolean needsScores,
SolrQueryRequest request,
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.
|
defaultParamsToMap, equals, getDefaultValue, getIndex, getInstance, getName, hashCode, ramBytesUsed, setDefaultValue, setIndex, toString, visit
classHash, createWeight, rewrite, sameClassAs, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getChildResources
public Object getValue()
public void setValue(Object value)
public boolean isRequired()
public void setRequired(boolean required)
public LinkedHashMap<String,Object> paramsToMap()
paramsToMap
in class Feature
protected void validate() throws FeatureException
Feature
validate
in class Feature
FeatureException
- Feature Exceptionpublic Feature.FeatureWeight createWeight(IndexSearcher searcher, boolean needsScores, SolrQueryRequest request, Query originalQuery, Map<String,String[]> efi) throws IOException
createWeight
in class Feature
IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.