Package org.apache.solr.ltr
Class LTRRescorer
- java.lang.Object
-
- org.apache.lucene.search.Rescorer
-
- org.apache.solr.ltr.LTRRescorer
-
- Direct Known Subclasses:
LTRInterleavingRescorer
public class LTRRescorer extends org.apache.lucene.search.Rescorer
Implements the rescoring logic. The top documents returned by solr with their original scores, will be processed by aLTRScoringQuery
that will assign a new score to each document. The top documents will be resorted based on the new score.
-
-
Field Summary
Fields Modifier and Type Field Description protected static Comparator<org.apache.lucene.search.ScoreDoc>
scoreComparator
-
Constructor Summary
Constructors Constructor Description LTRRescorer()
LTRRescorer(LTRScoringQuery scoringQuery)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.lucene.search.Explanation
explain(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Explanation firstPassExplanation, int docID)
static LTRScoringQuery.FeatureInfo[]
extractFeaturesInfo(LTRScoringQuery.ModelWeight modelWeight, int docid, Float originalDocScore, List<org.apache.lucene.index.LeafReaderContext> leafContexts)
protected static org.apache.lucene.search.Explanation
getExplanation(org.apache.lucene.search.IndexSearcher searcher, int docID, LTRScoringQuery rerankingQuery)
protected static org.apache.lucene.search.ScoreDoc[]
getFirstPassDocsRanked(org.apache.lucene.search.TopDocs firstPassTopDocs)
protected static void
heapAdjust(org.apache.lucene.search.ScoreDoc[] hits, int size, int root)
protected static void
heapify(org.apache.lucene.search.ScoreDoc[] hits, int size)
protected static void
logSingleHit(org.apache.lucene.search.IndexSearcher indexSearcher, LTRScoringQuery.ModelWeight modelWeight, int docid, LTRScoringQuery scoringQuery)
Call this method if thescoreSingleHit(int, int, int, ScoreDoc, int, org.apache.solr.ltr.LTRScoringQuery.ModelWeight.ModelScorer, ScoreDoc[])
method indicated that the document's feature info should be logged.org.apache.lucene.search.TopDocs
rescore(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.TopDocs firstPassTopDocs, int topN)
rescores the documents:void
scoreFeatures(org.apache.lucene.search.IndexSearcher indexSearcher, int topN, LTRScoringQuery.ModelWeight modelWeight, org.apache.lucene.search.ScoreDoc[] hits, List<org.apache.lucene.index.LeafReaderContext> leaves, org.apache.lucene.search.ScoreDoc[] reranked)
protected static boolean
scoreSingleHit(int topN, int docBase, int hitUpto, org.apache.lucene.search.ScoreDoc hit, int docID, LTRScoringQuery.ModelWeight.ModelScorer scorer, org.apache.lucene.search.ScoreDoc[] reranked)
Scores a single document and returns true if the document's feature info should be logged via thelogSingleHit(IndexSearcher, org.apache.solr.ltr.LTRScoringQuery.ModelWeight, int, LTRScoringQuery)
method.
-
-
-
Field Detail
-
scoreComparator
protected static final Comparator<org.apache.lucene.search.ScoreDoc> scoreComparator
-
-
Constructor Detail
-
LTRRescorer
public LTRRescorer()
-
LTRRescorer
public LTRRescorer(LTRScoringQuery scoringQuery)
-
-
Method Detail
-
heapAdjust
protected static void heapAdjust(org.apache.lucene.search.ScoreDoc[] hits, int size, int root)
-
heapify
protected static void heapify(org.apache.lucene.search.ScoreDoc[] hits, int size)
-
rescore
public org.apache.lucene.search.TopDocs rescore(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.TopDocs firstPassTopDocs, int topN) throws IOException
rescores the documents:- Specified by:
rescore
in classorg.apache.lucene.search.Rescorer
- Parameters:
searcher
- current IndexSearcherfirstPassTopDocs
- documents to rerank;topN
- documents to return;- Throws:
IOException
-
getFirstPassDocsRanked
protected static org.apache.lucene.search.ScoreDoc[] getFirstPassDocsRanked(org.apache.lucene.search.TopDocs firstPassTopDocs)
-
scoreFeatures
public void scoreFeatures(org.apache.lucene.search.IndexSearcher indexSearcher, int topN, LTRScoringQuery.ModelWeight modelWeight, org.apache.lucene.search.ScoreDoc[] hits, List<org.apache.lucene.index.LeafReaderContext> leaves, org.apache.lucene.search.ScoreDoc[] reranked) throws IOException
- Throws:
IOException
-
logSingleHit
protected static void logSingleHit(org.apache.lucene.search.IndexSearcher indexSearcher, LTRScoringQuery.ModelWeight modelWeight, int docid, LTRScoringQuery scoringQuery)
Call this method if thescoreSingleHit(int, int, int, ScoreDoc, int, org.apache.solr.ltr.LTRScoringQuery.ModelWeight.ModelScorer, ScoreDoc[])
method indicated that the document's feature info should be logged.
-
scoreSingleHit
protected static boolean scoreSingleHit(int topN, int docBase, int hitUpto, org.apache.lucene.search.ScoreDoc hit, int docID, LTRScoringQuery.ModelWeight.ModelScorer scorer, org.apache.lucene.search.ScoreDoc[] reranked) throws IOException
Scores a single document and returns true if the document's feature info should be logged via thelogSingleHit(IndexSearcher, org.apache.solr.ltr.LTRScoringQuery.ModelWeight, int, LTRScoringQuery)
method. Feature info logging is only necessary for the topN documents.- Throws:
IOException
-
explain
public org.apache.lucene.search.Explanation explain(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Explanation firstPassExplanation, int docID) throws IOException
- Specified by:
explain
in classorg.apache.lucene.search.Rescorer
- Throws:
IOException
-
getExplanation
protected static org.apache.lucene.search.Explanation getExplanation(org.apache.lucene.search.IndexSearcher searcher, int docID, LTRScoringQuery rerankingQuery) throws IOException
- Throws:
IOException
-
extractFeaturesInfo
public static LTRScoringQuery.FeatureInfo[] extractFeaturesInfo(LTRScoringQuery.ModelWeight modelWeight, int docid, Float originalDocScore, List<org.apache.lucene.index.LeafReaderContext> leafContexts) throws IOException
- Throws:
IOException
-
-