PhraseQuery

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PhraseQuery

baris.kazar
Hi,-

  how do i enforce the order of sequence of terms in the PhraseQuery
builder?
  Lucene docs are very hard to understand in terms of api descriptions.

https://lucene.apache.org/core/6_5_0/core/org/apache/lucene/search/PhraseQuery.html
Best regards


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: PhraseQuery

Michael Froh
Did you check the Javadoc for PhraseQuery.Builder?

https://lucene.apache.org/core/6_5_0/core/org/apache/lucene/search/PhraseQuery.Builder.html

Checking the source code, I see that the add method that takes a position
argument will throw an IllegalArgumentException if you try to add a Term in
a lower position than the previous Term. (That is, Term positions must be
non-decreasing.)

Hope that helps,
Michael

On Fri, 24 Jan 2020 at 09:45, <[hidden email]> wrote:

> Hi,-
>
>   how do i enforce the order of sequence of terms in the PhraseQuery
> builder?
>   Lucene docs are very hard to understand in terms of api descriptions.
>
>
> https://lucene.apache.org/core/6_5_0/core/org/apache/lucene/search/PhraseQuery.html
> Best regards
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: PhraseQuery

Atri Sharma-3
In reply to this post by baris.kazar
PhraseQuery enforces the order of terms specified and needs an exact
match of order of terms unless slop is specified.

When appending terms, term pos numbers need to be incremental in the builder

On Fri, Jan 24, 2020 at 11:15 PM <[hidden email]> wrote:

>
> Hi,-
>
>   how do i enforce the order of sequence of terms in the PhraseQuery
> builder?
>   Lucene docs are very hard to understand in terms of api descriptions.
>
> https://lucene.apache.org/core/6_5_0/core/org/apache/lucene/search/PhraseQuery.html
> Best regards
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


--
Regards,

Atri
Apache Concerted

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: PhraseQuery

baris.kazar
In reply to this post by Michael Froh
Thanks for the quick responses, i was having a bug in my code such that
i was building multiple PhraseQuery's instead of one PhraseQuery in a loop.

Then i was losing order of terms.

Best regards

On 1/24/20 12:54 PM, Michael Froh wrote:

> Did you check the Javadoc for PhraseQuery.Builder?
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lucene.apache.org_core_6-5F5-5F0_core_org_apache_lucene_search_PhraseQuery.Builder.html&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=nlG5z5NcNdIbQAiX-BKNeyLlULCbaezrgocEvPhQkl4&m=IKZsplnvxeAys8KTpnZUR9To3moViZLv2LQHnuL4uHQ&s=mgj0lNuzP2IfQzWZHxdRe4UQQ-n-e8Yy5abEIS1Ieik&e=
>
> Checking the source code, I see that the add method that takes a position
> argument will throw an IllegalArgumentException if you try to add a Term in
> a lower position than the previous Term. (That is, Term positions must be
> non-decreasing.)
>
> Hope that helps,
> Michael
>
> On Fri, 24 Jan 2020 at 09:45, <[hidden email]> wrote:
>
>> Hi,-
>>
>>    how do i enforce the order of sequence of terms in the PhraseQuery
>> builder?
>>    Lucene docs are very hard to understand in terms of api descriptions.
>>
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lucene.apache.org_core_6-5F5-5F0_core_org_apache_lucene_search_PhraseQuery.html&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=nlG5z5NcNdIbQAiX-BKNeyLlULCbaezrgocEvPhQkl4&m=IKZsplnvxeAys8KTpnZUR9To3moViZLv2LQHnuL4uHQ&s=8d1QBLJg0ltQqzGEk_Z40SzkBZsgdjglTrmyjnJ0rbs&e=
>> Best regards
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: PhraseQuery

baris.kazar
In reply to this post by Atri Sharma-3
Right, i am getting now expected behavior.

In the docs i wish the New York example would be continued for clarity
and consistence.

Best regards

On 1/24/20 12:55 PM, Atri Sharma wrote:

> PhraseQuery enforces the order of terms specified and needs an exact
> match of order of terms unless slop is specified.
>
> When appending terms, term pos numbers need to be incremental in the builder
>
> On Fri, Jan 24, 2020 at 11:15 PM <[hidden email]> wrote:
>> Hi,-
>>
>>    how do i enforce the order of sequence of terms in the PhraseQuery
>> builder?
>>    Lucene docs are very hard to understand in terms of api descriptions.
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lucene.apache.org_core_6-5F5-5F0_core_org_apache_lucene_search_PhraseQuery.html&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=nlG5z5NcNdIbQAiX-BKNeyLlULCbaezrgocEvPhQkl4&m=YTrEhjB-AYQP02G-oZgBw_-nGgrpoQxRk-rj1LzC_7Y&s=tFhbvjjjKk_Ud5XffGASKin-cHtEGc5SRQ1NKqxSFuU&e=
>> Best regards
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]