Package org.apache.solr.ltr.feature
Class SolrFeature
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.solr.ltr.feature.Feature
-
- org.apache.solr.ltr.feature.SolrFeature
-
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
public class SolrFeature extends Feature
This feature allows you to reuse any Solr query as a feature. The value of the feature will be the score of the given query for the current document. See Solr documentation of other parsers you can use as a feature. Example configurations:[ { "name": "isBook", "class": "org.apache.solr.ltr.feature.SolrFeature", "params":{ "fq": ["{!terms f=category}book"] } }, { "name": "documentRecency", "class": "org.apache.solr.ltr.feature.SolrFeature", "params": { "q": "{!func}recip( ms(NOW,publish_date), 3.16e-11, 1, 1)" } } ]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSolrFeature.SolrFeatureWeightWeight for a SolrFeature-
Nested classes/interfaces inherited from class org.apache.solr.ltr.feature.Feature
Feature.FeatureWeight
-
-
Constructor Summary
Constructors Constructor Description SolrFeature(String name, Map<String,Object> params)
-
Method Summary
All 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)StringgetDf()List<String>getFq()StringgetQ()LinkedHashMap<String,Object>paramsToMap()voidsetDf(String df)voidsetFq(List<String> fq)voidsetQ(String q)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.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
-
getDf
public String getDf()
-
setDf
public void setDf(String df)
-
getQ
public String getQ()
-
setQ
public void setQ(String q)
-
paramsToMap
public LinkedHashMap<String,Object> paramsToMap()
- Specified by:
paramsToMapin classFeature
-
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
-
validate
protected 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 classFeature- Throws:
FeatureException- Feature Exception
-
-