FAQ
Hi @all,

I'm a little confused about the behaviour of BooleanQuery. I have a custom
parser that analyzes some text and constrcuts an "ANDed" BooleanQuery. toString
delivers something like this:

(+field1:term1 +field2:term2)

Looks pretty normal to me, but the problem is it delivers no results (although
there are matching ones of course). What makes it even more confusing is the
fact that when I take the above query and use it with the QueryParser it works
and delivers the expected results...

Any ideas? Perhaps anyone who is able to reproduce it? Am I doing something
wrong or is there a bug?

Here is how I produce the BooleanQuery:

BooleanQuery bq = new BooleanQuery();
for (iterate over terms) {
t = new Term(field, term);
bq.add(new TermQuery(t), BooleanClause.Occur.MUST);
}

Any help appreciated, thanks in advance!

Oliver



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

Search Discussions

  • Erick Erickson at Feb 8, 2007 at 1:07 pm
    I assume it's a typo, but your for loop wouldn't produce your example as
    they'd all be the same field....

    But that said, I suspect that your QueryParser is analyzing the tokens you
    feed it differently than how they're included when you make your own
    BooleanQuery.

    So, here's what I'd do. Use Query.toString() for both your BooleanQuery and
    the query produced by QueryParser and see what's different, if anything.
    That'll certainly give you a clue. If your QueryParser uses, for instance,
    the StandardAnalyzer, it'll lowercase, remove most punctuation, etc, which
    you wouldn't get with your manually constructed BooleanQuery.

    And, of course, get Luke if you haven't gotten a copy already to examine
    your index and see the effects of using various analyzers on a query.

    Hope this helps
    Erick
    On 2/8/07, Oliver Hummel wrote:

    Hi @all,

    I'm a little confused about the behaviour of BooleanQuery. I have a custom
    parser that analyzes some text and constrcuts an "ANDed" BooleanQuery.
    toString
    delivers something like this:

    (+field1:term1 +field2:term2)

    Looks pretty normal to me, but the problem is it delivers no results
    (although
    there are matching ones of course). What makes it even more confusing is
    the
    fact that when I take the above query and use it with the QueryParser it
    works
    and delivers the expected results...

    Any ideas? Perhaps anyone who is able to reproduce it? Am I doing
    something
    wrong or is there a bug?

    Here is how I produce the BooleanQuery:

    BooleanQuery bq = new BooleanQuery();
    for (iterate over terms) {
    t = new Term(field, term);
    bq.add(new TermQuery(t), BooleanClause.Occur.MUST);
    }

    Any help appreciated, thanks in advance!

    Oliver



    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Oliver Hummel at Feb 8, 2007 at 1:49 pm
    Eric, thanks for your reply.
    I assume it's a typo, but your for loop wouldn't produce your example as
    they'd all be the same field....
    Actually there are three loops that add it for different fields... :-)
    So, here's what I'd do. Use Query.toString() for both your BooleanQuery and
    the query produced by QueryParser and see what's different, if anything.
    That'll certainly give you a clue. If your QueryParser uses, for instance,
    the StandardAnalyzer, it'll lowercase, remove most punctuation, etc, which
    you wouldn't get with your manually constructed BooleanQuery.
    It delivered exactly the same query.

    Meanwhile I think I got the problem. It seems to be related with redeploying in
    JBoss. Everytime I redeploy now without restarting the server it does not work
    anymore...

    Thanks!

    Oliver



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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedFeb 8, '07 at 9:32a
activeFeb 8, '07 at 1:49p
posts3
users2
websitelucene.apache.org

2 users in discussion

Oliver Hummel: 2 posts Erick Erickson: 1 post

People

Translate

site design / logo © 2022 Grokbase