hibernate search - Lucene phase query case insensitive -
i writing query exact match on 'city' field. field/property defined as:
@org.hibernate.search.annotations.field(index = index.yes, analyze = analyze.no, store = store.no) private string city;
if have value of "new york", want find match if user enters "new york", or variation of case. using standardanalyzer entity, know lowercase tokens. don't tokenize since want match phrase (analyze.no).
i tried lowercase search value, no luck.
query query = qb.phrase().onfield(.....).sentence(location.tolowercase()).createquery();
if don't lowercase search term , value 'new york', results returned. searching 'new york' not return result.
if tokenize (analyze.yes), other cities 'new jersey' returned. know can use wildcard query (searchterm*), hoping able case insensitive search on phrase. not sure if that's possible unless use wildcard.
thanks
it sounds want use analyzer emits entire text single token while lower-casing input. in case, want use analyze=analyze.yes
, while specifying appropriate analyzer (the answer here has code looks need) using analyzer=@analyzer(impl=your.fully.qualified.analyzer.class)
.
Comments
Post a Comment