lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject QueryParser refactoring
Date Mon, 07 Mar 2005 10:30:57 GMT
I've been making local changes to QueryParser to fix the operator 
precedence issues (i.e. currently A AND B OR C AND D parses to +A +B +C 

I've gotten every TestQueryParser test to pass without modification 
including this new one:

   public void testPrecedence() throws Exception {
     Query query1 = QueryParser.parse("A AND B OR C AND D", "field", new 
     Query query2 = QueryParser.parse("(A AND B) OR (C AND D)", "field", 
new WhitespaceAnalyzer());
     assertEquals(query1, query2);

except for this one from testQPA:

     assertQueryEquals("term AND NOT phrase term", qpAnalyzer,
                       "+term -\"phrase1 phrase2\" term");

The error I get is this:

junit.framework.AssertionFailedError: Query /term AND NOT phrase term/ 
yielded /(+term -"phrase1 phrase2") term/, expecting /+term -"phrase1 
phrase2" term/

My take is that the test is asserting the incorrect behavior that we 
want to fix.  Do others agree?

If we agree, then I'll adjust the test to expect /(+term -"phrase1 
phrase2") term/ instead.  The next steps will be:

	- Rename my work to PrecedenceQueryParser.jj (name up for discussion 
if desired)
	- Adjust the build file to take this new JavaCC file into account (I'm 
also switching back to using <javacc> and adding a <jjdoc> in to 
document the grammars we use).
	- Deprecate our current QueryParser and refer users to the new 

I'm switching back to <javacc> in the build as it works fine with 
JavaCC 3.2 and does dependency checking automatically.  The only issue 
is that <javacc> currently only does dependency checking, such that if 
the .jj is newer than the generated .java file then generation is 
skipped - this makes it tricky to force generation.  I'll also add a 
way to force generation by removing the generated .java file, and I'll 
also probably add a force="..." attribute to <javacc> since I'm also an 
Ant committer :) (to be present in Ant 1.6.3 hopefully).  Any other 
<javacc> wishes out there?

Any thoughts on any of the above?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message