Lucene - Core
  1. Lucene - Core
  2. LUCENE-3328

Specialize BooleanQuery if all clauses are TermQueries


    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.4, 4.0-ALPHA
    • Fix Version/s: 4.0-ALPHA
    • Component/s: core/search
    • Labels:
    • Lucene Fields:
      New, Patch Available


      During work on LUCENE-3319 I ran into issues with BooleanQuery compared to PhraseQuery in the exact case. If I disable scoring on PhraseQuery and bypass the position matching, essentially doing a conjunction match, ExactPhraseScorer beats plain boolean scorer by 40% which is a sizeable gain. I converted a ConjunctionScorer to use DocsEnum directly but still didn't get all the 40% from PhraseQuery. Yet, it turned out with further optimizations this gets very close to PhraseQuery. The biggest gain here came from converting the hand crafted loop in ConjunctionScorer#doNext to a for loop which seems to be less confusing to hotspot. In this particular case I think code specialization makes lots of sense since BQ with TQ is by far one of the most common queries.

      I will upload a patch shortly

      1. LUCENE-3328.patch
        11 kB
        Simon Willnauer
      2. LUCENE-3328.patch
        8 kB
        Robert Muir
      3. LUCENE-3328.patch
        16 kB
        Simon Willnauer


        Simon Willnauer created issue -
        Simon Willnauer made changes -
        Field Original Value New Value
        Attachment LUCENE-3328.patch [ 12487138 ]
        Robert Muir made changes -
        Attachment LUCENE-3328.patch [ 12487141 ]
        Robert Muir made changes -
        Fix Version/s 3.4 [ 12316675 ]
        Simon Willnauer made changes -
        Attachment LUCENE-3328.patch [ 12487226 ]
        Simon Willnauer made changes -
        Assignee Simon Willnauer [ simonw ]
        Simon Willnauer made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Uwe Schindler made changes -
        Status Resolved [ 5 ] Closed [ 6 ]


          • Assignee:
            Simon Willnauer
            Simon Willnauer
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: