lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: Using Fuzzysearch with MultiFieldQueryParser
Date Fri, 25 Mar 2011 10:04:29 GMT
You'd be better off building a BooleanQuery.

BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(...), ...);
bq.add(new FuzzyQuery(...),. ...);

See BooleanClause.Occur for options on MUST, SHOULD etc.


On Thu, Mar 24, 2011 at 5:48 PM, Deepak Konidena
<> wrote:
> Hi,
> I am using MultiFieldQueryParser with a custom analyzer for parsing search text.
> Now,  when I say
> MultiFieldQueryParser qp = new MultiFieldQueryParser(Version,  new String[] {"field1",
"field2", "field3"}, customAnalyzer);
> qp.setDefaultOperator(QueryParser.AND_OPERATOR);
> Query query = qp.parse("term1");
> The query that gets built is
> field1:term1 field2:term1 field3:term1
> I am assuming input is treated as a TermQuery and is being searched against the respective
fields (field1, field2, field3) in case of single term and in case of multiple search terms,
a BooleanQuery with an AND of all the individual TermQueries.
> Now what if  I want to do something like,
> Perform a TermQuery on term1 against all the fields, perform a FuzzyQuery on term2, RangeQuery
on term3, etc..
> And finally do an AND on all the terms?
> Please let me know, if am assuming anything wrong here. My understanding is that to break
individual terms to be searched using different queries, I will need to implement a custom
QueryParser. If so, how would I start about implementing that?
> Thanks
> Deepak Konidena

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

View raw message