Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-10469

ConstantScoreQuery doesn't propagate its score mode correctly

Details

    • Task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 9.1
    • None
    • None
    • New

    Description

      We just noticed a performance bug on Elasticsearch that if you issue a search request sorted by field and the query is a MatchAllDocsQuery then everything works as expected.

      But if you change the query to be a MatchAllDocsQuery within a ConstantScoreQuery then the query suddenly visits all matching documents. This is due to the fact that ConstantScoreQuery always passes COMPLETE_NO_SCORES to the inner weight, and thet the MatchAllDocsQuery's optimized bulk scorer performs a brute-force for-loop over the documents to score unless the score mode is not exhaustive.

      The fix consists of making ConstantScoreQuery propagate a non-exhaustive score mode to the inner weight when the score mode that is passed to the ConstantScoreQuery is not exhaustive itself.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jpountz Adrien Grand
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m