lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ces3w <ce...@ccri.com>
Subject Querying Lucene property for exact value
Date Thu, 05 May 2011 18:03:21 GMT
Hi, 

I am new to Lucene, so I apologize if this has been answered, but I've had
no success finding the answer after googling around.  I am using Compass as
a Lucene front end and have run into an issue in querying Lucene docs.  I am
looking for a way to search a property based on it's complete and exact
value, not based on a keyword within the property.  

An example is that I have an Activity field that can be one of many values
including 'patrol', 'unit patrol', 'police patrol', etc.  With my query, I
would like to only return 'patrol' items and nothing else.  Is there a way
to do this??  My current querying code is below. This returns all items with
'patrol' in it.

Note: values and field are variables passed to the method indicating
possible values the lucene field can be.

CompassQueryBuilder.CompassBooleanQueryBuilder boolQuery =
queryBuilder.bool();
for (String value : values) {
        CompassQuery t = queryBuilder.term(field, value);
        boolQuery.addShould(t);
}
return boolQuery.toQuery();

Any help would be greatly appreciated.

Thanks,

Chelsea

--
View this message in context: http://lucene.472066.n3.nabble.com/Querying-Lucene-property-for-exact-value-tp2904431p2904431.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

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


Mime
View raw message