You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Gus Kormeier <gu...@altrec.com> on 2004/02/09 20:07:33 UTC
MultiFieldQueryParser.setOperator()
Sorry if this is a newbie question,
I want to change the default search to use AND instead of OR when combining
words. The default Lucene does a great job at finding documents, but I
would like to return 30 instead of 3,000 hits when someone types multiple
words.
For instance here:
http://www.greatoutdoors.com/go/search.jsp?query=north+face+jacket
I am using:
String [] fields = {"name","brand","description","teaser" };
Analyzer analyzer = new StandardAnalyzer();
Query query = MultiFieldQueryParser.parse(line, fields, analyzer);
I was going to try something like this:
MultiFieldQueryParser mfqp = new MultiFieldQueryParser(line /* what
is this string to the constructor? */ ,analyzer);
mfqp.setOperator(mfqp.DEFAULT_OPERATOR_AND);
Query query = MultiFieldQueryParser.parse(line, fields, analyzer);
But parse(String line,String [] fields,Analyzer a) is static, so
setOperator() has no effect on it.
I was expecting to see a constructor where I could set the String[] for
which fields to search, but it isn't there(API 1.3). Otherwise the
MultiFieldQueryParser works great for my purposes.
Am I reading the API wrong? Is there a way to search Multi fields and
setOperator()?
One solution I can see, would it be better to Index all of the fields into
one blob of a field as well, and just search off of that?
Thanks in Advance,
-Gus
P.S. Have been very impressed with the speed and flexibility of Lucene so
far.
Gus Kormeier - tech | gusk@altrec.com <<m...@altrec.com>> |
425.605.4008
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org