[ https://issues.apache.org/jira/browse/LUCENE-7550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dawid Weiss resolved LUCENE-7550. --------------------------------- Resolution: Won't Fix Assignee: Dawid Weiss Sorry to return to this so late. This is a known behavior of how QueryParser works, Paweł. Quoting Hoss: "If the default operator is set to “And” then the behavior is just plain weird.". You can read about the Boolean logic and query parser behavior at [1]. Also, check out PrecedenceQueryParser which should return the result you expect. [1] https://lucidworks.com/2011/12/28/why-not-and-or-and-not/ > QueryParser parses query differently depending on the default operator > ---------------------------------------------------------------------- > > Key: LUCENE-7550 > URL: https://issues.apache.org/jira/browse/LUCENE-7550 > Project: Lucene - Core > Issue Type: Bug > Reporter: Dawid Weiss > Assignee: Dawid Weiss > Priority: Minor > > As explained by Paweł Róg on java-user [1], the output of parsing the queries > below is different depending on the default operator. This looks odd and > should be investigated. > {code} > QueryParser parser = new QueryParser("test", new WhitespaceAnalyzer()); > parser.setDefaultOperator(QueryParser.Operator.AND); > Query query = parser.parse("foo AND bar OR baz "); > System.out.println(query.toString()); > parser.setDefaultOperator(QueryParser.Operator.OR); > query = parser.parse("foo AND bar OR baz "); > System.out.println(query.toString()); > {code} > Results in : > {code} > +test:foo test:bar test:baz > +test:foo +test:bar test:baz > {code} > [1] > http://mail-archives.apache.org/mod_mbox/lucene-java-user/201611.mbox/browser -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org