Following is an output from my test code, where the left hand side is
the query and right hand side is the parsed query print. There are two
sets , one with the default operator set to OR , the other with
default set to AND

The output looks funny for the for the first example when the
operator is set to AND

Is this a bug. Can some one point me to a bug if it is or help me
understand so I can explain this behavior.

-Antony Sequeira

Tets code output follows:
Testing with default operator set to OR
(fooooo AND barrrr OR "fooooo barrrr") -> +xxxx:fooooo +xxxx:barrrr
xxxx:"fooooo barrrr"
(fooooo AND (barrrr OR "fooooo barrrr")) -> +xxxx:fooooo +(xxxx:barrrr
xxxx:"fooooo barrrr")
((fooooo AND barrrr) OR "fooooo barrrr") -> (+xxxx:fooooo
+xxxx:barrrr) xxxx:"fooooo barrrr"
Testing with default operator set to AND
(fooooo AND barrrr OR "fooooo barrrr") -> +xxxx:fooooo xxxx:barrrr
xxxx:"fooooo barrrr"
(fooooo AND (barrrr OR "fooooo barrrr")) -> +xxxx:fooooo +(xxxx:barrrr
xxxx:"fooooo barrrr")
((fooooo AND barrrr) OR "fooooo barrrr") -> (+xxxx:fooooo
+xxxx:barrrr) xxxx:"fooooo barrrr"

Test code follows:

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.queryParser.QueryParser.Operator;
import org.apache.lucene.search.Query;

public class QueryParserBug {

String [] testQueries = {
"(fooooo AND barrrr OR \"fooooo barrrr\")",
"(fooooo AND (barrrr OR \"fooooo barrrr\"))",
"((fooooo AND barrrr) OR \"fooooo barrrr\") ",

QueryParser queryParser;

private Analyzer analyzer;

private void log(String msg) {

QueryParserBug() throws Exception {
analyzer = new StandardAnalyzer();
queryParser = new QueryParser("xxxx",analyzer);

public static void main(String [] args) {
try {
new QueryParserBug().test(Operator.OR);
new QueryParserBug().test(Operator.AND);
} catch (Exception e) {

private void test(Operator opr) throws ParseException {
log("Testing with default operator set to " + opr);
for (String query: testQueries) {
Query lq = queryParser.parse(query);
log(query + " -> " + lq.toString());



To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupjava-user @
postedJun 21, '07 at 1:13a
activeJun 21, '07 at 1:13a

1 user in discussion

Antony Sequeira: 1 post



site design / logo © 2022 Grokbase