Mailing List Archive

Classic QueryParser, StandardQueryParser, Quotes
Dear reader,

I'm trying to test lucene 8.2.0 as key-value store;

I know that there are specialized ones like lmdb etc...

As key I have a StringField, keys can contain space(s), e. g. "a b". I
know I should use TermQuery.

But I've been playing with classic QueryParser, which does not match the
indexed keys,

not with »a backslash space b«

nor with »quote a space b quote«.

Now the funny part: The StandardQueryParser does work when querying "a
b". It does not match an additional key "a a b", so StandardQueryParser
seems not to do a phrase query despite both query parsers refer to the
same syntax description.

Does StandardQueryParser takes field type into account when building the
query?

Kind regards, Jochen


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Classic QueryParser, StandardQueryParser, Quotes [ In reply to ]
1> Add &debug=query to the query and look at the parsed query returned. That’ll tell you a _lot_ about this kind of question.

2> look at the analysis page of the admin UI for the core and see how your field definition handles the tokens once they’re through <1>.

Best,
Erick

> On Oct 10, 2019, at 11:18 AM, Jochen Barth <jpunktbarth@gmail.com> wrote:
>
> Dear reader,
>
> I'm trying to test lucene 8.2.0 as key-value store;
>
> I know that there are specialized ones like lmdb etc...
>
> As key I have a StringField, keys can contain space(s), e. g. "a b". I know I should use TermQuery.
>
> But I've been playing with classic QueryParser, which does not match the indexed keys,
>
> not with »a backslash space b«
>
> nor with »quote a space b quote«.
>
> Now the funny part: The StandardQueryParser does work when querying "a b". It does not match an additional key "a a b", so StandardQueryParser seems not to do a phrase query despite both query parsers refer to the same syntax description.
>
> Does StandardQueryParser takes field type into account when building the query?
>
> Kind regards, Jochen
>
>
> ---------------------------------------------------------------------
> 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
Re: Classic QueryParser, StandardQueryParser, Quotes [ In reply to ]
A StrField field is not tokenized. So, do not expect "a b" to match "a a b". Lucene will generate a single term from "a b", and a single term from "a a b", so obviously, they do not match.

If you want to match these two texts, change the field to TextField and use the appropriate analysis (standard standard analyser is a good start). Run your analysis again.
Regards
Ameer

Sent from Mailspring (https://getmailspring.com/), the best free email app for work
On Oct 11 2019, at 2:18 am, Jochen Barth <jpunktbarth@gmail.com> wrote:
> Dear reader,
>
> I'm trying to test lucene 8.2.0 as key-value store;
> I know that there are specialized ones like lmdb etc...
> As key I have a StringField, keys can contain space(s), e. g. "a b". I
> know I should use TermQuery.
>
> But I've been playing with classic QueryParser, which does not match the
> indexed keys,
>
> not with »a backslash space b«
> nor with »quote a space b quote«.
> Now the funny part: The StandardQueryParser does work when querying "a
> b". It does not match an additional key "a a b", so StandardQueryParser
> seems not to do a phrase query despite both query parsers refer to the
> same syntax description.
>
> Does StandardQueryParser takes field type into account when building the
> query?
>
> Kind regards, Jochen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
Re: Classic QueryParser, StandardQueryParser, Quotes [ In reply to ]
As Ameer mentioned use TextField to phrases.
Thanks

Sent from my iPhone

> On Oct 10, 2019, at 11:33 AM, Ameer Albahem <ameer.albahem@gmail.com> wrote:
>
> A StrField field is not tokenized. So, do not expect "a b" to match "a a b". Lucene will generate a single term from "a b", and a single term from "a a b", so obviously, they do not match.
>
> If you want to match these two texts, change the field to TextField and use the appropriate analysis (standard standard analyser is a good start). Run your analysis again.
> Regards
> Ameer
>
> Sent from Mailspring (https://urldefense.proofpoint.com/v2/url?u=https-3A__getmailspring.com_&d=DwIFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=nlG5z5NcNdIbQAiX-BKNeyLlULCbaezrgocEvPhQkl4&m=bUDFLWAXcYKcSby1WcpgQRHdw-ywqcVOqivrFB2dpPg&s=ILGjOnTIv6Tcn6_ztewrrUmtcWvhNoNGjuYslioLhUM&e= ), the best free email app for work
>> On Oct 11 2019, at 2:18 am, Jochen Barth <jpunktbarth@gmail.com> wrote:
>> Dear reader,
>>
>> I'm trying to test lucene 8.2.0 as key-value store;
>> I know that there are specialized ones like lmdb etc...
>> As key I have a StringField, keys can contain space(s), e. g. "a b". I
>> know I should use TermQuery.
>>
>> But I've been playing with classic QueryParser, which does not match the
>> indexed keys,
>>
>> not with »a backslash space b«
>> nor with »quote a space b quote«.
>> Now the funny part: The StandardQueryParser does work when querying "a
>> b". It does not match an additional key "a a b", so StandardQueryParser
>> seems not to do a phrase query despite both query parsers refer to the
>> same syntax description.
>>
>> Does StandardQueryParser takes field type into account when building the
>> query?
>>
>> Kind regards, Jochen
>>
>> ---------------------------------------------------------------------
>> 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