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 rhys J <rh...@gmail.com> on 2019/11/15 17:15:42 UTC

using NOT or - to exclude results with a textField type

I'm trying to exclude results based on the documentation about the boolean
NOT symbol, but I keep getting errors.

I've tried:

http://localhost:8983/solr/debt/select?q=clt_ref_no:-”owl-2924-8”

and

http://localhost:8983/solr/debt/select?q=clt_ref_no:NOT”owl-2924-8”

I have tried with and without quotes too.

Am I not able to use the NOT with a textField?

Here are the errors I get from the browser:

"msg":"org.apache.solr.search.SyntaxError: Cannot parse
'clt_ref_no:-”=owl-2924-8”': Encountered \" \"-\" \"- \"\" at line 1,
column 11.\nWas expecting one of:\n    <BAREOPER> ...\n    \"(\" ...\n
   \"*\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <PREFIXTERM> ...\n
   <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\"
...\n    <LPARAMS> ...\n    \"filter(\" ...\n    <NUMBER> ...\n    ",

Thanks,

Rhys

Re: using NOT or - to exclude results with a textField type

Posted by Shawn Heisey <ap...@elyograg.org>.
On 11/15/2019 10:15 AM, rhys J wrote:
> I'm trying to exclude results based on the documentation about the boolean
> NOT symbol, but I keep getting errors.
> 
> I've tried:
> 
> http://localhost:8983/solr/debt/select?q=clt_ref_no:-”owl-2924-8”
> 
> and
> 
> http://localhost:8983/solr/debt/select?q=clt_ref_no:NOT”owl-2924-8”
> 
> I have tried with and without quotes too.
> 
> Am I not able to use the NOT with a textField?

You've got the NOT keyword and the - character misplaced.

q=*:* AND NOT clt_ref_no:owl-2924-8
q=*:* -clt_ref_no:owl-2924-8

In a URL, use a + sign in place of a space.

In a simple case like this, the purely negative query can be detected by 
Solr and fixed internally, but for the most part, purely negative 
queries do not work.  You have to start with something and then 
subtract, you can't subtract from nothing.  That is why my examples have 
the all docs (*:*) starting point.

The errors are a little strange, but I'm guessing the misplaced 
characters are resulting in something the query parser doesn't know how 
to handle.

Thanks,
Shawn

Re: using NOT or - to exclude results with a textField type

Posted by Erick Erickson <er...@gmail.com>.
On of Solr’s little quirks… Solr does _not_ implement Boolean logic. See: 
https://lucidworks.com/post/why-not-and-or-and-not/

What you want is something like:
../select/q=*:* -clt_ref_no:“owl-2924-8”

Best,
Erick

> On Nov 15, 2019, at 12:15 PM, rhys J <rh...@gmail.com> wrote:
> 
> I'm trying to exclude results based on the documentation about the boolean
> NOT symbol, but I keep getting errors.
> 
> I've tried:
> 
> http://localhost:8983/solr/debt/select?q=clt_ref_no:-”owl-2924-8”
> 
> and
> 
> http://localhost:8983/solr/debt/select?q=clt_ref_no:NOT”owl-2924-8”
> 
> I have tried with and without quotes too.
> 
> Am I not able to use the NOT with a textField?
> 
> Here are the errors I get from the browser:
> 
> "msg":"org.apache.solr.search.SyntaxError: Cannot parse
> 'clt_ref_no:-”=owl-2924-8”': Encountered \" \"-\" \"- \"\" at line 1,
> column 11.\nWas expecting one of:\n    <BAREOPER> ...\n    \"(\" ...\n
>   \"*\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <PREFIXTERM> ...\n
>   <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\"
> ...\n    <LPARAMS> ...\n    \"filter(\" ...\n    <NUMBER> ...\n    ",
> 
> Thanks,
> 
> Rhys