Github user jimczi commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/495#discussion_r232184501
  
    --- Diff: 
lucene/core/src/java/org/apache/lucene/search/ConstantScoreScorer.java ---
    @@ -58,6 +58,14 @@ public float getMaxScore(int upTo) throws IOException {
         return score;
       }
     
    +  @Override
    +  public void setMinCompetitiveScore(float minScore) throws IOException {
    +    float minScoreDown = Math.nextDown(minScore);
    --- End diff --
    
    Yes this is because you need to add an indirection in 
`ConstantScoreScorer#iterator`. Something like:
    ````
     @Override
      public DocIdSetIterator iterator() {
        // add indirection so that if 'it' is updated then it will
        // be taken into account
        return new DocIdSetIterator() {
          @Override
          public int nextDoc() throws IOException {
            return doc = disi.nextDoc();
          }
    
          @Override
          public int docID() {
            return doc;
          }
    
          @Override
          public long cost() {
            return disi.cost();
          }
    
          @Override
          public int advance(int target) throws IOException {
            return doc = disi.advance(target);
          }
        };
      }
    ````
    You replace `disi` with an empty one when the min score is greater than the 
query score so you  cannot return it directly there. You also need to save the 
current doc to make sure that you don't lost it when you reset the disi.  


---

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

Reply via email to