diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 022a28e7e00..c562a856f3b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -80,6 +80,8 @@ Other Changes * SOLR-10748: Make stream.body configurable and disabled by default (janhoy) +* SOLR-10964: Reduce SolrIndexSearcher casting in LTRRescorer. (Christine Poerschke) + ================== 7.0.0 ================== Versions of Major Components diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java index 33c9a3624ef..59b764bb935 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/LTRRescorer.java @@ -116,8 +116,7 @@ public class LTRRescorer extends Rescorer { final LTRScoringQuery.ModelWeight modelWeight = (LTRScoringQuery.ModelWeight) searcher .createNormalizedWeight(scoringQuery, true); - final SolrIndexSearcher solrIndexSearch = (SolrIndexSearcher) searcher; - scoreFeatures(solrIndexSearch, firstPassTopDocs,topN, modelWeight, hits, leaves, reranked); + scoreFeatures(searcher, firstPassTopDocs,topN, modelWeight, hits, leaves, reranked); // Must sort all documents that we reranked, and then select the top Arrays.sort(reranked, new Comparator() { @Override @@ -138,7 +137,7 @@ public class LTRRescorer extends Rescorer { return new TopDocs(firstPassTopDocs.totalHits, reranked, reranked[0].score); } - public void scoreFeatures(SolrIndexSearcher solrIndexSearch, TopDocs firstPassTopDocs, + public void scoreFeatures(IndexSearcher indexSearcher, TopDocs firstPassTopDocs, int topN, LTRScoringQuery.ModelWeight modelWeight, ScoreDoc[] hits, List leaves, ScoreDoc[] reranked) throws IOException { @@ -183,8 +182,8 @@ public class LTRRescorer extends Rescorer { reranked[hitUpto] = hit; // if the heap is not full, maybe I want to log the features for this // document - if (featureLogger != null) { - featureLogger.log(hit.doc, scoringQuery, solrIndexSearch, + if (featureLogger != null && indexSearcher instanceof SolrIndexSearcher) { + featureLogger.log(hit.doc, scoringQuery, (SolrIndexSearcher)indexSearcher, modelWeight.getFeaturesInfo()); } } else if (hitUpto == topN) { @@ -200,8 +199,8 @@ public class LTRRescorer extends Rescorer { if (hit.score > reranked[0].score) { reranked[0] = hit; heapAdjust(reranked, topN, 0); - if (featureLogger != null) { - featureLogger.log(hit.doc, scoringQuery, solrIndexSearch, + if (featureLogger != null && indexSearcher instanceof SolrIndexSearcher) { + featureLogger.log(hit.doc, scoringQuery, (SolrIndexSearcher)indexSearcher, modelWeight.getFeaturesInfo()); } }