I'm a bit confused by this: *********** 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.
************************** Are you saying that if you're searching on "patrol", you'd like to get back only doc 1 below? 1> 'patrol', 2> 'unit patrol', 3> 'police patrol' If so, you'll need to index the field as single terms, what analyzer are you using? Warning: I'm Compass-naive, so.... Best Erick On Thu, May 5, 2011 at 2:03 PM, ces3w <ce...@ccri.com> wrote: > 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-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org