lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: QueryParser refactoring
Date Mon, 07 Mar 2005 16:25:46 GMT
I've gone ahead and committed my PrecedenceQueryParser.  I cloned 
TestQueryParser into TestPrecedenceQueryParser and fixed the one item 
mentioned below.

Please give this new PrecedenceQueryParser a try and report back any 
issues you find with it.  I'm still on the steep side of the JavaCC 
learning curve so there are quite possibly cases that it does not 
handle properly, though it does pass all of the test cases from 
QueryParser (with the noted exception).

In my local code, I have deprecated QueryParser and will commit that 
once I'm comfortable that this new one is at least a decent 


On Mar 7, 2005, at 5:30 AM, Erik Hatcher wrote:

> 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 +D).
> 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 WhitespaceAnalyzer());
>     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 
> PrecedenceQueryParser.
> 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?
> 	Erik
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message