lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amg qas <amg...@gmail.com>
Subject Re: Phrase query on multiple fields
Date Sat, 22 Jan 2011 18:55:57 GMT
Thanks Ian. The alternative approach you have mentioned works for me.

-amg

On Thu, Jan 20, 2011 at 6:59 AM, Ian Lea <ian.lea@gmail.com> wrote:
> 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 <amgqas@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-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
>
>

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