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

BooleanQuery.rewrite could easily optimize some simple cases

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.5, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Follow-up of SOLR-8251: APIs and user interfaces sometimes encourage to write BooleanQuery instances that are not optimal, for instance a typical case that happens often with Solr/Elasticsearch is to send a request that has a MatchAllDocsQuery as a query and some filter, which could be executed more efficiently by directly wrapping the filter into a ConstantScoreQuery.

      Here are some ideas of rewrite operations that BooleanQuery could perform:

      • remove FILTER clauses when they are also a MUST clause
      • rewrite queries of the form "+: #filter" to a ConstantScoreQuery(filter)
      • rewrite to a MatchNoDocsQuery when a clause that is a MUST or FILTER clause is also a MUST_NOT clause

        Attachments

        1. LUCENE-6889.patch
          25 kB
          Adrien Grand
        2. LUCENE-6889.patch
          26 kB
          Adrien Grand

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jpountz Adrien Grand
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: