You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Zheng Lin Edwin Yeo <ed...@gmail.com> on 2017/04/07 10:43:28 UTC

Error in Not Contains query

Hi,

When I do the Not Contains query, I get the following error when I do it in
the following way:

*Not working*
1) When put the "-" sign before the {!parent which}

http://localhost:8983/solr/test/select?q=contentType_s:Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-01-01T00:00:00Z]&fq=-{!parent%20which=%22contentType_s:Header%22}matNo_s:(*88060*%20*88061*)&json.facet={client_s:{type:terms,field:client_s,%20limit:200,%20offset:0,%20mincount:1}}&facet.threads=-1&fl=null&rows=0

This is the error message that I get:
{
  "responseHeader":{
    "zkConnected":true,
    "status":400,
    "QTime":1},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.parser.ParseException"],
    "msg":"org.apache.solr.search.SyntaxError: Cannot parse
'matNo_s:(*88060*': Encountered \"<EOF>\" at line 1, column 28.\r\nWas
expecting one of:\r\n    <AND> ...\r\n    <OR> ...\r\n    <NOT> ...\r\n
 \"+\" ...\r\n    \"-\" ...\r\n    <BAREOPER> ...\r\n    \"(\" ...\r\n
 \")\" ...\r\n    \"*\" ...\r\n    \"^\" ...\r\n    <QUOTED> ...\r\n
 <TERM> ...\r\n    <FUZZY_SLOP> ...\r\n    <PREFIXTERM> ...\r\n
 <WILDTERM> ...\r\n    <REGEXPTERM> ...\r\n    \"[\" ...\r\n    \"{\"
...\r\n    <LPARAMS> ...\r\n    \"filter(\" ...\r\n    <NUMBER> ...\r\n
 ",
    "code":400}}
*Not working*
2) When I put the "-" sign just before the matNo

http://localhost:8983/solr/test/select?q=contentType_s:Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-01-01T00:00:00Z]&fq={!parent%20which=%22contentType_s:Header%22}-matNo_s:(*88060*%20*88061*)&json.facet={client_s:{type:terms,field:client_s,%20limit:200,%20offset:0,%20mincount:1}}&facet.threads=-1&fl=null&rows=0

There is no result returned for this:
{
  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":0},
  "response":{"numFound":0,"start":0,"docs":[]
  },
  "facets":{
    "count":0}}

*Working*
I need to include the field parentId_s:* to match all query first

http://localhost:8983/solr/test/select?q=contentType_s:Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-01-01T00:00:00Z]&fq={!parent%20which=%22contentType_s:Header%22}parentId_s:*
AND -matNo_s:(88060*
88061*)&json.facet={client_s:{type:terms,field:client_s,%20limit:200,%20offset:0,%20mincount:1}}&facet.threads=-1&fl=null&rows=0

However, this is an inefficient way to get the Not Contain. By right, we
should be able to get the results from the first two examples. Can this be
consider a bug?

I'm using Solr 6.4.2.


Regards,
Edwin

Re: Error in Not Contains query

Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
Hi Mikhail,

Thanks for your reply.

Your suggestion works, but I found that there is a slight difference with
the number of records returned between both of the queries, even though the
rest of the values are the same.

I'm still finding out which of them are correct, but would the algorithm
caused some results to return differently?

Regards,
Edwin


On 7 April 2017 at 20:10, Mikhail Khludnev <gg...@gmail.com> wrote:

> Hello, Edwin.
> {!foo} syntax is surprising when a query string contains space. Thus, it.s
> gonna be fine if there is no space in child query. You can solve it with
> referencing
> fq=-{!parent%20which=%22contentType_s:Header%22
> v=$childq}&childq=matNo_s:(*88060*%20*88061*)
> <http://localhost:8983/solr/test/select?q=contentType_s:
> Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> 01-01T00:00:00Z]&fq=-{!parent%20which=%22contentType_s:
> Header%22}matNo_s:(*88060*%20*88061*)&json.facet={client_s:{
> type:terms,field:client_s,%20limit:200,%20offset:0,%
> 20mincount:1}}&facet.threads=-1&fl=null&rows=0>
>
> 07 апр. 2017 г. 13:43 пользователь "Zheng Lin Edwin Yeo" <
> edwinyeozl@gmail.com> написал:
>
> > Hi,
> >
> > When I do the Not Contains query, I get the following error when I do it
> in
> > the following way:
> >
> > *Not working*
> > 1) When put the "-" sign before the {!parent which}
> >
> > http://localhost:8983/solr/test/select?q=contentType_s:
> > Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> > 01-01T00:00:00Z]&fq=-{!parent%20which=%22contentType_s:
> > Header%22}matNo_s:(*88060*%20*88061*)&json.facet={client_s:{
> > type:terms,field:client_s,%20limit:200,%20offset:0,%
> > 20mincount:1}}&facet.threads=-1&fl=null&rows=0
> >
> > This is the error message that I get:
> > {
> >   "responseHeader":{
> >     "zkConnected":true,
> >     "status":400,
> >     "QTime":1},
> >   "error":{
> >     "metadata":[
> >       "error-class","org.apache.solr.common.SolrException",
> >       "root-error-class","org.apache.solr.parser.ParseException"],
> >     "msg":"org.apache.solr.search.SyntaxError: Cannot parse
> > 'matNo_s:(*88060*': Encountered \"<EOF>\" at line 1, column 28.\r\nWas
> > expecting one of:\r\n    <AND> ...\r\n    <OR> ...\r\n    <NOT> ...\r\n
> >  \"+\" ...\r\n    \"-\" ...\r\n    <BAREOPER> ...\r\n    \"(\" ...\r\n
> >  \")\" ...\r\n    \"*\" ...\r\n    \"^\" ...\r\n    <QUOTED> ...\r\n
> >  <TERM> ...\r\n    <FUZZY_SLOP> ...\r\n    <PREFIXTERM> ...\r\n
> >  <WILDTERM> ...\r\n    <REGEXPTERM> ...\r\n    \"[\" ...\r\n    \"{\"
> > ...\r\n    <LPARAMS> ...\r\n    \"filter(\" ...\r\n    <NUMBER> ...\r\n
> >  ",
> >     "code":400}}
> > *Not working*
> > 2) When I put the "-" sign just before the matNo
> >
> > http://localhost:8983/solr/test/select?q=contentType_s:
> > Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> > 01-01T00:00:00Z]&fq={!parent%20which=%22contentType_s:
> > Header%22}-matNo_s:(*88060*%20*88061*)&json.facet={client_
> > s:{type:terms,field:client_s,%20limit:200,%20offset:0,%
> > 20mincount:1}}&facet.threads=-1&fl=null&rows=0
> >
> > There is no result returned for this:
> > {
> >   "responseHeader":{
> >     "zkConnected":true,
> >     "status":0,
> >     "QTime":0},
> >   "response":{"numFound":0,"start":0,"docs":[]
> >   },
> >   "facets":{
> >     "count":0}}
> >
> > *Working*
> > I need to include the field parentId_s:* to match all query first
> >
> > http://localhost:8983/solr/test/select?q=contentType_s:
> > Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> > 01-01T00:00:00Z]&fq={!parent%20which=%22contentType_s:
> > Header%22}parentId_s:*
> > AND -matNo_s:(88060*
> > 88061*)&json.facet={client_s:{type:terms,field:client_s,%
> > 20limit:200,%20offset:0,%20mincount:1}}&facet.threads=-1&fl=null&rows=0
> >
> > However, this is an inefficient way to get the Not Contain. By right, we
> > should be able to get the results from the first two examples. Can this
> be
> > consider a bug?
> >
> > I'm using Solr 6.4.2.
> >
> >
> > Regards,
> > Edwin
> >
>

Re: Error in Not Contains query

Posted by Mikhail Khludnev <gg...@gmail.com>.
Hello, Edwin.
{!foo} syntax is surprising when a query string contains space. Thus, it.s
gonna be fine if there is no space in child query. You can solve it with
referencing
fq=-{!parent%20which=%22contentType_s:Header%22
v=$childq}&childq=matNo_s:(*88060*%20*88061*)
<http://localhost:8983/solr/test/select?q=contentType_s:Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-01-01T00:00:00Z]&fq=-{!parent%20which=%22contentType_s:Header%22}matNo_s:(*88060*%20*88061*)&json.facet={client_s:{type:terms,field:client_s,%20limit:200,%20offset:0,%20mincount:1}}&facet.threads=-1&fl=null&rows=0>

07 апр. 2017 г. 13:43 пользователь "Zheng Lin Edwin Yeo" <
edwinyeozl@gmail.com> написал:

> Hi,
>
> When I do the Not Contains query, I get the following error when I do it in
> the following way:
>
> *Not working*
> 1) When put the "-" sign before the {!parent which}
>
> http://localhost:8983/solr/test/select?q=contentType_s:
> Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> 01-01T00:00:00Z]&fq=-{!parent%20which=%22contentType_s:
> Header%22}matNo_s:(*88060*%20*88061*)&json.facet={client_s:{
> type:terms,field:client_s,%20limit:200,%20offset:0,%
> 20mincount:1}}&facet.threads=-1&fl=null&rows=0
>
> This is the error message that I get:
> {
>   "responseHeader":{
>     "zkConnected":true,
>     "status":400,
>     "QTime":1},
>   "error":{
>     "metadata":[
>       "error-class","org.apache.solr.common.SolrException",
>       "root-error-class","org.apache.solr.parser.ParseException"],
>     "msg":"org.apache.solr.search.SyntaxError: Cannot parse
> 'matNo_s:(*88060*': Encountered \"<EOF>\" at line 1, column 28.\r\nWas
> expecting one of:\r\n    <AND> ...\r\n    <OR> ...\r\n    <NOT> ...\r\n
>  \"+\" ...\r\n    \"-\" ...\r\n    <BAREOPER> ...\r\n    \"(\" ...\r\n
>  \")\" ...\r\n    \"*\" ...\r\n    \"^\" ...\r\n    <QUOTED> ...\r\n
>  <TERM> ...\r\n    <FUZZY_SLOP> ...\r\n    <PREFIXTERM> ...\r\n
>  <WILDTERM> ...\r\n    <REGEXPTERM> ...\r\n    \"[\" ...\r\n    \"{\"
> ...\r\n    <LPARAMS> ...\r\n    \"filter(\" ...\r\n    <NUMBER> ...\r\n
>  ",
>     "code":400}}
> *Not working*
> 2) When I put the "-" sign just before the matNo
>
> http://localhost:8983/solr/test/select?q=contentType_s:
> Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> 01-01T00:00:00Z]&fq={!parent%20which=%22contentType_s:
> Header%22}-matNo_s:(*88060*%20*88061*)&json.facet={client_
> s:{type:terms,field:client_s,%20limit:200,%20offset:0,%
> 20mincount:1}}&facet.threads=-1&fl=null&rows=0
>
> There is no result returned for this:
> {
>   "responseHeader":{
>     "zkConnected":true,
>     "status":0,
>     "QTime":0},
>   "response":{"numFound":0,"start":0,"docs":[]
>   },
>   "facets":{
>     "count":0}}
>
> *Working*
> I need to include the field parentId_s:* to match all query first
>
> http://localhost:8983/solr/test/select?q=contentType_s:
> Header%20AND%20date_dt:[2016-01-01T00:00:00Z%20TO%202017-
> 01-01T00:00:00Z]&fq={!parent%20which=%22contentType_s:
> Header%22}parentId_s:*
> AND -matNo_s:(88060*
> 88061*)&json.facet={client_s:{type:terms,field:client_s,%
> 20limit:200,%20offset:0,%20mincount:1}}&facet.threads=-1&fl=null&rows=0
>
> However, this is an inefficient way to get the Not Contain. By right, we
> should be able to get the results from the first two examples. Can this be
> consider a bug?
>
> I'm using Solr 6.4.2.
>
>
> Regards,
> Edwin
>