No and No. Alternative approaches might include building a general "contents" field holding any/all searchable fields or building up the query yourself. The latter is quite straightforward:
BooleanQuery bq = new BooleanQuery(); PhraseQuery pq1 = ...; PhraseQuery pq2 = ...; bq.add(pq1, ...); bq.add(pq2, ...); etc. -- Ian. On Thu, Jan 20, 2011 at 3:13 AM, amg qas <amg...@gmail.com> wrote: > Hi, > > I have two question regarding phrase query : > > 1) How can I execute a phrase query over multiple fields ? I can only > get PhraseQuery to work over a single field - For eg something like > this : > > PhraseQuery query = new PhraseQuery(); > query.setSlop(10); > String[] phrase = { "george", "bush" }; > for (String word : phrase) { > query.add(new Term(field, word)); > } > > 2) Is there a way to execute a phrase query along with > MultiFieldQueryParser ? So if I have a query {A B} and fields F1 and > F2, I want the query to be something like this : > (F1:A F2:A) (F1:B F2:B) (F1:"A B"~10 F2:"A B"~10) > > MultiFieldQueryParser queryParser = new MultiFieldQueryParser( > Version.LUCENE_30, fields, new > SnowballAnalyzer( > Version.LUCENE_30, "English"), > boosts); > Query query = queryParser.parse(queryString); > > Thanks, > amg > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org