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

BooleanQuery Does Not Work With One Query indicated as MUST_NOT

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: core/search
    • Labels:
      None
    • Environment:

      JDK 1.5, Lucene 1.9.1, Windows XP

      Description

      The following code won't create a boolean query which will return anything but a passed in query:

      BooleanQuery result = new BooleanQuery();
      result.add(myQuery, BooleanClause.Occur.MUST_NOT);

      I'll get no results if I use this query. As a workaround, I have to add a MatchAllDocsQuery in order to get it to work.

      BooleanQuery result = new BooleanQuery();
      result.add(new MatchAllDocsQuery(), BooleanClause.Occur.SHOULD);
      result.add(myQuery, BooleanClause.Occur.MUST_NOT);

      Maybe this is intended???? If so, perhaps the JavaDocs should be updated to indicate this.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nshupe Nicholaus Shupe
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: