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 Rob Nikander <ro...@gmail.com> on 2014/08/28 15:53:11 UTC
How to not span fields with phrase query?
Hi,
If I have document with multiple fields "title"
title: A B C
title: X Y Z
A phrase search for title:"B C X" matches this document. Can I prevent
that?
thanks,
Rob
Re: How to not span fields with phrase query?
Posted by cr...@gmail.com.
`getPositionIncrementGap`
Sent from my BlackBerry® smartphone
-----Original Message-----
From: Rob Nikander <ro...@gmail.com>
Date: Thu, 28 Aug 2014 10:26:00
To: <ja...@lucene.apache.org>
Reply-To: java-user@lucene.apache.org
Subject: Re: How to not span fields with phrase query?
Thank you for the explanation. I subclassed Analyzer and overrode
`getPositionIncrementGap` for this field. It appears to have worked.
Rob
On Thu, Aug 28, 2014 at 10:21 AM, Michael Sokolov <
msokolov@safaribooksonline.com> wrote:
> Usually that's referred to as multiple "values" for the same field; in the
> index there is no distinction between title:C and title:X as far as which
> field they are in -- they're in the same field.
>
> If you want to prevent phrase queries from matching B C X, insert a
> position gap between C and X; so A B C would be positions 0, 1, 2, and X,
> Y, Z might be 4, 5, 6 instead of 3, 4, 5, which is probably what you have
> now
>
> -Mike
>
>
> On 08/28/2014 09:53 AM, Rob Nikander wrote:
>
>> Hi,
>>
>> If I have document with multiple fields "title"
>>
>> title: A B C
>> title: X Y Z
>>
>> A phrase search for title:"B C X" matches this document. Can I prevent
>> that?
>>
>> thanks,
>> Rob
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
Re: How to not span fields with phrase query?
Posted by cr...@gmail.com.
`getPositionIncrementGap`
Sent from my BlackBerry® smartphone
-----Original Message-----
From: Rob Nikander <ro...@gmail.com>
Date: Thu, 28 Aug 2014 10:26:00
To: <ja...@lucene.apache.org>
Reply-To: java-user@lucene.apache.org
Subject: Re: How to not span fields with phrase query?
Thank you for the explanation. I subclassed Analyzer and overrode
`getPositionIncrementGap` for this field. It appears to have worked.
Rob
On Thu, Aug 28, 2014 at 10:21 AM, Michael Sokolov <
msokolov@safaribooksonline.com> wrote:
> Usually that's referred to as multiple "values" for the same field; in the
> index there is no distinction between title:C and title:X as far as which
> field they are in -- they're in the same field.
>
> If you want to prevent phrase queries from matching B C X, insert a
> position gap between C and X; so A B C would be positions 0, 1, 2, and X,
> Y, Z might be 4, 5, 6 instead of 3, 4, 5, which is probably what you have
> now
>
> -Mike
>
>
> On 08/28/2014 09:53 AM, Rob Nikander wrote:
>
>> Hi,
>>
>> If I have document with multiple fields "title"
>>
>> title: A B C
>> title: X Y Z
>>
>> A phrase search for title:"B C X" matches this document. Can I prevent
>> that?
>>
>> thanks,
>> Rob
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
Re: How to not span fields with phrase query?
Posted by Rob Nikander <ro...@gmail.com>.
Thank you for the explanation. I subclassed Analyzer and overrode
`getPositionIncrementGap` for this field. It appears to have worked.
Rob
On Thu, Aug 28, 2014 at 10:21 AM, Michael Sokolov <
msokolov@safaribooksonline.com> wrote:
> Usually that's referred to as multiple "values" for the same field; in the
> index there is no distinction between title:C and title:X as far as which
> field they are in -- they're in the same field.
>
> If you want to prevent phrase queries from matching B C X, insert a
> position gap between C and X; so A B C would be positions 0, 1, 2, and X,
> Y, Z might be 4, 5, 6 instead of 3, 4, 5, which is probably what you have
> now
>
> -Mike
>
>
> On 08/28/2014 09:53 AM, Rob Nikander wrote:
>
>> Hi,
>>
>> If I have document with multiple fields "title"
>>
>> title: A B C
>> title: X Y Z
>>
>> A phrase search for title:"B C X" matches this document. Can I prevent
>> that?
>>
>> thanks,
>> Rob
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
Re: How to not span fields with phrase query?
Posted by Michael Sokolov <ms...@safaribooksonline.com>.
Usually that's referred to as multiple "values" for the same field; in
the index there is no distinction between title:C and title:X as far as
which field they are in -- they're in the same field.
If you want to prevent phrase queries from matching B C X, insert a
position gap between C and X; so A B C would be positions 0, 1, 2, and
X, Y, Z might be 4, 5, 6 instead of 3, 4, 5, which is probably what you
have now
-Mike
On 08/28/2014 09:53 AM, Rob Nikander wrote:
> Hi,
>
> If I have document with multiple fields "title"
>
> title: A B C
> title: X Y Z
>
> A phrase search for title:"B C X" matches this document. Can I prevent
> that?
>
> thanks,
> Rob
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org