FAQ
Hi,

I have experience some strange things when dealing with Lucene queries.
I've read some threads on this list and realize that Lucene shouldn't be
seen as a complete boolean query language. However I try to understand
the Lucene-way and have one example that I wonder if someone can help me
to clarify.

I wish to create a query that gives me all persons outside us OR having
Smith as last name, ie something like (Country != us or LastName == smith)
This is what I've tried:

+((-Country:us) (+LastName:smith))
results in only all with LastName smith. Ie all the non-Smith's outside
us will not be included.

(-Country:us) (+LastName:smith)
results in all documents. I guess this is since both groups are SHOULD.

It seem to have something to do with the MUST_NOT before Country, since
the query below works more as expected:
+((+Country:us) (+LastName:smith))
results in only all persons in us and all persons in all countries with
last name smith.

Is this not possible to do with Lucene or am I missing something?

Best regards
Henric Müller
Trillian AB - www.spamdrain.net




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

Search Discussions

  • AHMET ARSLAN at Aug 25, 2009 at 10:45 am

    --- On Tue, 8/25/09, Henric Müller wrote:

    From: Henric Müller <henric@trillian.se>
    Subject: Lucene query syntax using grouping, MUST, MUST_NOT and SHOULD
    To: java-user@lucene.apache.org
    Date: Tuesday, August 25, 2009, 12:20 PM
    Hi,

    I have experience some strange things when dealing with
    Lucene queries. I've read some threads on this list and
    realize that Lucene shouldn't be seen as a complete boolean
    query language. However I try to understand the Lucene-way
    and have one example that I wonder if someone can help me to
    clarify.

    I wish to create a query that gives me all persons outside
    us OR having Smith as last name, ie something like (Country
    != us or LastName == smith)
    (Country:[* TO *] NOT Country:us) OR LastName:smith

    "Note: The NOT operator cannot be used with just one term. For example, the following search will return no results: NOT "jakarta apache""[1]

    [1] http://lucene.apache.org/java/2_4_1/queryparsersyntax.html#NOT




    ---------------------------------------------------------------------
    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
postedAug 25, '09 at 9:20a
activeAug 25, '09 at 10:45a
posts2
users2
websitelucene.apache.org

2 users in discussion

Henric Müller: 1 post AHMET ARSLAN: 1 post

People

Translate

site design / logo © 2022 Grokbase