opensubscriber
   Find in this group all groups
 
Unknown more information…

j : java-user@lucene.apache.org 7 March 2005 • 6:30PM -0500

QueryParser refactoring
by Erik Hatcher

REPLY TO AUTHOR
 
REPLY TO GROUP




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: java-user-unsubscribe@luce...
For additional commands, e-mail: java-user-help@luce...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.