lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Konidena <deepak.konid...@cornell.edu>
Subject Re: Using Fuzzysearch with MultiFieldQueryParser
Date Fri, 25 Mar 2011 14:18:25 GMT
Ian,

I think you're right. Boolean query is what I am looking for.

Thanks.

On 3/25/11 6:04 AM, "Ian Lea" <ian.lea@gmail.com> wrote:

>You'd be better off building a BooleanQuery.
>
>BooleanQuery bq = new BooleanQuery();
>bq.add(new TermQuery(...), ...);
>bq.add(new FuzzyQuery(...),. ...);
>etc
>
>See BooleanClause.Occur for options on MUST, SHOULD etc.
>
>
>--
>Ian.
>
>On Thu, Mar 24, 2011 at 5:48 PM, Deepak Konidena
><deepak.konidena@cornell.edu> 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: java-user-unsubscribe@lucene.apache.org
>For additional commands, e-mail: java-user-help@lucene.apache.org
>


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