cammiemw commented on a change in pull request #2097:
URL: https://github.com/apache/lucene-solr/pull/2097#discussion_r532905390



##########
File path: lucene/core/src/java/org/apache/lucene/search/IndriAndScorer.java
##########
@@ -0,0 +1,59 @@
+package org.apache.lucene.search;
+
+import java.io.IOException;
+import java.util.List;
+
+/** Combines scores of subscorers. If a subscorer does not contain
+ *  the docId, a smoothing score is calculated for that 
+ *  document/subscorer combination.
+ */
+public class IndriAndScorer extends IndriDisjunctionScorer {
+  
+  protected IndriAndScorer(Weight weight, List<Scorer> subScorers,
+      ScoreMode scoreMode, float boost) throws IOException {
+    super(weight, subScorers, scoreMode, boost);
+  }
+  
+  @Override
+  public float score(List<Scorer> subScorers) throws IOException {
+    int docId = this.docID();
+    return scoreDoc(subScorers, docId);
+  }
+  
+  @Override
+  public float smoothingScore(List<Scorer> subScorers, int docId)
+      throws IOException {
+    return scoreDoc(subScorers, docId);
+  }
+  
+  private float scoreDoc(List<Scorer> subScorers, int docId)
+      throws IOException {
+    double score = 0;
+    double boostSum = 0.0;
+    for (Scorer scorer : subScorers) {
+      if (scorer instanceof IndriScorer) {
+        IndriScorer indriScorer = (IndriScorer) scorer;
+        int scorerDocId = indriScorer.docID();
+        //If the query exists in the document, score the document
+        //Otherwise, compute a smoothing score, which acts like an idf
+        //for subqueries/terms
+        if (docId == scorerDocId) {

Review comment:
       Done :-)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to