Hi,
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) {
System.out.println(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) {
e.printStackTrace();
}
}
private void test(Operator opr) throws ParseException {
log("Testing with default operator set to " + opr);
queryParser.setDefaultOperator(opr);
for (String query: testQueries) {
Query lq = queryParser.parse(query);
log(query + " -> " + lq.toString());
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]