You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Subhajit Das <Su...@live.com> on 2021/03/23 17:39:42 UTC

StrField not matching content "equals" way

Hi,

I have a field with type string (StrField). The data in it is like “abc xyz”. But when I search for “xyz”, I am getting one document containing “abc xyz”.

Using q and fq is same for this.

When I filter like field=”xyz” it works, but field=xyz dosen’t.

Thanks and Regards,
Subhajit

RE: StrField not matching content "equals" way

Posted by Subhajit Das <su...@live.com>.
Thanks Alexandre for clarification.

From: Alexandre Rafalovitch<ma...@gmail.com>
Sent: 24 March 2021 01:45 AM
To: users@solr.apache.org<ma...@solr.apache.org>
Subject: Re: StrField not matching content "equals" way

That's correct behavior for the query parser you are with
(default/lucene it seems):
https://solr.apache.org/guide/8_8/the-standard-query-parser.html.

You could explore other query parsers, e.g. field:
https://solr.apache.org/guide/8_8/other-parsers.html#field-query-parser
, possibly combined with parameter substitution.

Regards,
   Alex.

On Tue, 23 Mar 2021 at 15:58, Subhajit Das <su...@live.com> wrote:
>
> Hi Alessandro,
>
> Thanks for the suggestion.
>
> The issue is that, without the double quotes, query like “ field: ola hello hi ” parses into “ field: ola (text:hello text:hi) ”. Which means that it is breaking in space and considering only first one. And all parts are or to each other. Wrapping in double quotes, solves the issue.
>
> Is this the default behaviour?
>
> Thanks,
> Subhajit
>
> From: Alessandro Benedetti<ma...@sease.io>
> Sent: 24 March 2021 12:06 AM
> To: users@solr.apache.org<ma...@solr.apache.org>
> Cc: solr-user@lucene.apache.org<ma...@lucene.apache.org>
> Subject: Re: StrField not matching content "equals" way
>
> Hi Subhajit,
> that's weird, if you use StrField no text analysis happens.
> This means in the inverted index a single token is built for the text "abc
> xyz".
> So neither the query field:xyz neither the phrase query field:"xyz" is
> supposed to return you such document.
>
> I would recommend running the query with debug=query enabled in the request
> parameters (
> https://solr.apache.org/guide/6_6/common-query-parameters.html#CommonQueryParameters-ThedebugParameter
>  )
> In this way, we'll see how the query is parsed and the real fields involved
> in the query.
>
> Cheers
> --------------------------
> Alessandro Benedetti
> Apache Lucene/Solr Committer
> Director, R&D Software Engineer, Search Consultant
> www.sease.io<http://www.sease.io>
>
>
> On Tue, 23 Mar 2021 at 17:39, Subhajit Das <Su...@live.com> wrote:
>
> >
> > Hi,
> >
> > I have a field with type string (StrField). The data in it is like “abc
> > xyz”. But when I search for “xyz”, I am getting one document containing
> > “abc xyz”.
> >
> > Using q and fq is same for this.
> >
> > When I filter like field=”xyz” it works, but field=xyz dosen’t.
> >
> > Thanks and Regards,
> > Subhajit
> >
>


Re: StrField not matching content "equals" way

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
That's correct behavior for the query parser you are with
(default/lucene it seems):
https://solr.apache.org/guide/8_8/the-standard-query-parser.html.

You could explore other query parsers, e.g. field:
https://solr.apache.org/guide/8_8/other-parsers.html#field-query-parser
, possibly combined with parameter substitution.

Regards,
   Alex.

On Tue, 23 Mar 2021 at 15:58, Subhajit Das <su...@live.com> wrote:
>
> Hi Alessandro,
>
> Thanks for the suggestion.
>
> The issue is that, without the double quotes, query like “ field: ola hello hi ” parses into “ field: ola (text:hello text:hi) ”. Which means that it is breaking in space and considering only first one. And all parts are or to each other. Wrapping in double quotes, solves the issue.
>
> Is this the default behaviour?
>
> Thanks,
> Subhajit
>
> From: Alessandro Benedetti<ma...@sease.io>
> Sent: 24 March 2021 12:06 AM
> To: users@solr.apache.org<ma...@solr.apache.org>
> Cc: solr-user@lucene.apache.org<ma...@lucene.apache.org>
> Subject: Re: StrField not matching content "equals" way
>
> Hi Subhajit,
> that's weird, if you use StrField no text analysis happens.
> This means in the inverted index a single token is built for the text "abc
> xyz".
> So neither the query field:xyz neither the phrase query field:"xyz" is
> supposed to return you such document.
>
> I would recommend running the query with debug=query enabled in the request
> parameters (
> https://solr.apache.org/guide/6_6/common-query-parameters.html#CommonQueryParameters-ThedebugParameter
>  )
> In this way, we'll see how the query is parsed and the real fields involved
> in the query.
>
> Cheers
> --------------------------
> Alessandro Benedetti
> Apache Lucene/Solr Committer
> Director, R&D Software Engineer, Search Consultant
> www.sease.io<http://www.sease.io>
>
>
> On Tue, 23 Mar 2021 at 17:39, Subhajit Das <Su...@live.com> wrote:
>
> >
> > Hi,
> >
> > I have a field with type string (StrField). The data in it is like “abc
> > xyz”. But when I search for “xyz”, I am getting one document containing
> > “abc xyz”.
> >
> > Using q and fq is same for this.
> >
> > When I filter like field=”xyz” it works, but field=xyz dosen’t.
> >
> > Thanks and Regards,
> > Subhajit
> >
>

RE: StrField not matching content "equals" way

Posted by Subhajit Das <su...@live.com>.
Hi Alessandro,

Thanks for the suggestion.

The issue is that, without the double quotes, query like “ field: ola hello hi ” parses into “ field: ola (text:hello text:hi) ”. Which means that it is breaking in space and considering only first one. And all parts are or to each other. Wrapping in double quotes, solves the issue.

Is this the default behaviour?

Thanks,
Subhajit

From: Alessandro Benedetti<ma...@sease.io>
Sent: 24 March 2021 12:06 AM
To: users@solr.apache.org<ma...@solr.apache.org>
Cc: solr-user@lucene.apache.org<ma...@lucene.apache.org>
Subject: Re: StrField not matching content "equals" way

Hi Subhajit,
that's weird, if you use StrField no text analysis happens.
This means in the inverted index a single token is built for the text "abc
xyz".
So neither the query field:xyz neither the phrase query field:"xyz" is
supposed to return you such document.

I would recommend running the query with debug=query enabled in the request
parameters (
https://solr.apache.org/guide/6_6/common-query-parameters.html#CommonQueryParameters-ThedebugParameter
 )
In this way, we'll see how the query is parsed and the real fields involved
in the query.

Cheers
--------------------------
Alessandro Benedetti
Apache Lucene/Solr Committer
Director, R&D Software Engineer, Search Consultant
www.sease.io<http://www.sease.io>


On Tue, 23 Mar 2021 at 17:39, Subhajit Das <Su...@live.com> wrote:

>
> Hi,
>
> I have a field with type string (StrField). The data in it is like “abc
> xyz”. But when I search for “xyz”, I am getting one document containing
> “abc xyz”.
>
> Using q and fq is same for this.
>
> When I filter like field=”xyz” it works, but field=xyz dosen’t.
>
> Thanks and Regards,
> Subhajit
>


Re: StrField not matching content "equals" way

Posted by Alessandro Benedetti <a....@sease.io>.
Hi Subhajit,
that's weird, if you use StrField no text analysis happens.
This means in the inverted index a single token is built for the text "abc
xyz".
So neither the query field:xyz neither the phrase query field:"xyz" is
supposed to return you such document.

I would recommend running the query with debug=query enabled in the request
parameters (
https://solr.apache.org/guide/6_6/common-query-parameters.html#CommonQueryParameters-ThedebugParameter
 )
In this way, we'll see how the query is parsed and the real fields involved
in the query.

Cheers
--------------------------
Alessandro Benedetti
Apache Lucene/Solr Committer
Director, R&D Software Engineer, Search Consultant
www.sease.io


On Tue, 23 Mar 2021 at 17:39, Subhajit Das <Su...@live.com> wrote:

>
> Hi,
>
> I have a field with type string (StrField). The data in it is like “abc
> xyz”. But when I search for “xyz”, I am getting one document containing
> “abc xyz”.
>
> Using q and fq is same for this.
>
> When I filter like field=”xyz” it works, but field=xyz dosen’t.
>
> Thanks and Regards,
> Subhajit
>