lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henric Müller <>
Subject Lucene query syntax using grouping, MUST, MUST_NOT and SHOULD
Date Tue, 25 Aug 2009 09:20:12 GMT

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 -

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

View raw message