lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Jain <Eric.J...@isb-sib.ch>
Subject Re: Appending * to each search term
Date Fri, 17 Mar 2006 12:51:50 GMT
Florian Hanke wrote:
> I'd like to append an * (create a WildcardQuery) to each search term in 
> a query, such that a query that is entered as e.g. "term1 AND term2" is 
> modified (effectively) to "term1* AND term2*".
> Parsing the search string is not very elegant (of course). I'm thinking 
> that overriding QueryParser#get(Boolean etc.)Query is the way to go, the 
> way it's designed. But still, extracting terms and injecting them back 
> in while operating on specific Query classes does not seem the way to go.
> Can anyone perhaps suggest a nice alternative?

Perhaps you could subclass the QueryParser and override the getFieldQuery 
method:

protected Query getFieldQuery(String field, String term) {
   return new PrefixQuery(new Term(field, term));
}

---------------------------------------------------------------------
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