FAQ
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

[PATCH] QueryParser not handling queries containing AND and OR correctly





------- Additional Comments From morus.walter@gmx.de 2004-02-12 18:13 -------
Thanks for you effort Otis.

I wasn't aware of the test cases and used only my own ones.

When I run the tests now, I do get these errors.
I had a closer look and find that these errors are due to intentional changes.

First I changed the test cases to deal with null queries returned from the query
parser, that is I changed the function assertQueryEquals to
public void assertQueryEquals(String query, Analyzer a, String result)
throws Exception {
Query q = getQuery(query, a);
String s = q != null ? q.toString("field") : "null";
if (!s.equals(result)) {
fail("Query /" + query + "/ yielded /" + s
+ "/, expecting /" + result + "/");
}
}

(the change is the construction of the result string 'String s = ...').

Then I get the following errors:

[junit] Testcase:
testSimple(org.apache.lucene.queryParser.TestQueryParser): FAILED
[junit] Query /a OR !b/ yielded /a/, expecting /a -b/

intentional:
a OR !b means all documents that contain a or that don't contain b.
So this cannot be expressed by a single boolean query since it would implement a
AND !b. So a OR !b gets a OR (!b) and !b is a boolean query containing only
prohibited terms, which cannot be searched.
Therefor it's dropped.
I asked how to deal with that on the mailing list
(http://issues.apache.org/eyebrowse/ReadMsg?listName=lucene-user@jakarta.apache.org&msgNo=6497)
and Otis suggested to return null for such queries,
which means that it will get dropped.

[junit] Testcase:
testNumber(org.apache.lucene.queryParser.TestQueryParser): FAILED
[junit] Query /3/ yielded /null/, expecting //
...
[junit] Testcase: testQPA(org.apache.lucene.queryParser.TestQueryParser): FAILED
[junit] Query /stop/ yielded /null/, expecting //

Also intentional. Empty queries return null now, instead of a boolean
query containing no query.
Same question on the mailing list.

[junit] Testcase: testBoost(org.apache.lucene.queryParser.TestQueryParser):
FAILED
[junit] null
This is from
StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(new String[]{"on"});
QueryParser qp = new QueryParser("field", oneStopAnalyzer);
Query q = qp.parse("on^1.0");
assertNotNull(q);
which is also a query containing only stopwords, that returns null now.


So I think this raises the question again, what should be the result of an empty
query?
A boolean query containing no clauses doesn't make much sense to me (the only
reason to use this would be compatiblity, since this is the old behavior).
For queries (and subqueries) containing only stopwords, an alternative would be
to raise an exception.

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

Search Discussions

  • Bugzilla at Feb 12, 2004 at 6:38 pm
    DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
    RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
    <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
    ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
    INSERTED IN THE BUG DATABASE.

    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

    [PATCH] QueryParser not handling queries containing AND and OR correctly





    ------- Additional Comments From cutting@apache.org 2004-02-12 18:38 -------
    It is convenient to have an empty query string parsed as an empty BooleanQuery.
    That makes it much simpler to, e.g., construct a query from a form, where some
    fields may be empty. One needn't check for a null result from the parser, but
    can always unconditionally add the parsed query to the full query being composed.

    Back-compatiblity is also a good reason. Changing this will likely break a lot
    of applications when they upgrade, which is never nice.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
  • Bugzilla at Feb 12, 2004 at 8:24 pm
    DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
    RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
    <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
    ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
    INSERTED IN THE BUG DATABASE.

    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

    [PATCH] QueryParser not handling queries containing AND and OR correctly





    ------- Additional Comments From halleux.jf@skynet.be 2004-02-12 20:24 -------
    I had the same question when I submitted the last two patches to the
    QueryParser: what should an empty query return? This was the cause of some
    internal problems for handling stopwords within the QueryParser.

    Returning null from BooleanQuery broke "only" broke three tests in
    TestQueryParser, but fixed a lot of abnormal behaviors. Testing for an empty
    string appeared more of a dirty hack, but would do the trick too.

    I noticed that they were several patches in the queue for the QueryParser. Is
    there anybody that is taking care of them?

    Jean-Francois Halleux

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
  • Bugzilla at Feb 12, 2004 at 10:57 pm
    DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
    RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
    <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
    ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
    INSERTED IN THE BUG DATABASE.

    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

    [PATCH] QueryParser not handling queries containing AND and OR correctly





    ------- Additional Comments From otis@apache.org 2004-02-12 22:57 -------
    One of the Lucene developers will take care of them.
    I noticed there are several of them, which means there will be problems applying
    them.
    I am currently very busy, and will not get to this in at least another week or two.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
  • Otis Gospodnetic at Feb 12, 2004 at 11:00 pm
    Lucene peeps, note the fairly active patch contributers and a longer
    than usual patch queue, especially patches for the always problematic
    QueryParser.
    If anyone has time to take a look, apply, and test these
    patches....please.

    Otis

    --- bugzilla@apache.org wrote:
    DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
    RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
    <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
    ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
    INSERTED IN THE BUG DATABASE.

    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

    [PATCH] QueryParser not handling queries containing AND and OR
    correctly





    ------- Additional Comments From otis@apache.org 2004-02-12 22:57
    -------
    One of the Lucene developers will take care of them.
    I noticed there are several of them, which means there will be
    problems applying
    them.
    I am currently very busy, and will not get to this in at least
    another week or two.

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

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
  • Erik Hatcher at Feb 13, 2004 at 12:27 am
    I'm personally quite weary of applying all of these changes to
    QueryParser without spending a lot of time analyzing the ramifications.
    As Doug noted, backwards compatibility is practically a necessity,
    unless there are benefits to be gained by breaking it.

    Erik
    On Feb 12, 2004, at 6:00 PM, Otis Gospodnetic wrote:

    Lucene peeps, note the fairly active patch contributers and a longer
    than usual patch queue, especially patches for the always problematic
    QueryParser.
    If anyone has time to take a look, apply, and test these
    patches....please.

    Otis

    --- bugzilla@apache.org wrote:
    DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
    RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
    <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
    ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
    INSERTED IN THE BUG DATABASE.

    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

    [PATCH] QueryParser not handling queries containing AND and OR
    correctly





    ------- Additional Comments From otis@apache.org 2004-02-12 22:57
    -------
    One of the Lucene developers will take care of them.
    I noticed there are several of them, which means there will be
    problems applying
    them.
    I am currently very busy, and will not get to this in at least
    another week or two.

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

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

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
  • Bugzilla at Feb 15, 2004 at 5:51 pm
    DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
    RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
    <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820>.
    ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
    INSERTED IN THE BUG DATABASE.

    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25820

    [PATCH] QueryParser not handling queries containing AND and OR correctly





    ------- Additional Comments From morus.walter@gmx.de 2004-02-15 17:52 -------
    Two comments on Dougs arguments:

    - an empty query will not result in an empty (or null) query but raise a parser
    exception. So if it should, this would have to be changed.
    The only situation where empty (or null) queries occur is, when a query only
    contains stopwords (or, with my patch, contains only prohibited terms).
    - while it may be conveniant in some cases to have an empty query as the result,
    I would like to distinguish between empty queries and queries returning an empty
    result. So if an empty query is returned I'd like to have a simple way of
    testing for that.
    I suggest a 'isEmpty()' method for the query object, which can be implemented in
    the query object always returning false and be overwritten for boolean queries,
    where it returns true unless one of clauses is a nonempty query.
    Currently you can only use the toString() method to test for empty queries or
    have to distinguish the type of query object and if its boolean query look into
    it's details yourself.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categorieslucene
postedFeb 12, '04 at 6:13p
activeFeb 15, '04 at 5:51p
posts7
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase