FAQ
Ian,

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

Thanks.
On 3/25/11 6:04 AM, "Ian Lea" 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
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

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
groupjava-user @
categorieslucene
postedMar 24, '11 at 5:49p
activeMar 25, '11 at 2:19p
posts3
users2
websitelucene.apache.org

2 users in discussion

Deepak Konidena: 2 posts Ian Lea: 1 post

People

Translate

site design / logo © 2022 Grokbase