using NOT or - to exclude results with a textField type

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

using NOT or - to exclude results with a textField type

rhys J
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
Reply | Threaded
Open this post in threaded view
|

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

Erick Erickson
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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

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

Shawn Heisey-2
In reply to this post by rhys J
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