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 Peter Sch�tt <ne...@pstt.de> on 2013/04/15 18:03:25 UTC
Query Parser OR AND and NOT
Hallo,
I do not really understand the query language of the SOLR-Queryparser.
I use SOLR 4.2 und I have nearly 200000 sample address records in the
SOLR-Database.
I only use the "q" field in the SOLR Admin Web GUI and every other
controls on this website is on default.
First category:
zip:30* numFound=2896
city:H* OR zip:30* numFound=12519
city:H* AND zip:30* numFound=376
These results seems to me correct.
Now I tried with negations:
!city:H* numFound:194577 (seems to be correct)
!city:H* AND zip:30* numFound:2520 (seems to be correct)
!city:H* OR zip:30* numFound:2520 (!! this is wrong !!)
Or do I do not understand something?
(!city:H*) OR zip:30* numFound: 2896
This is also wrong.
Thanks for any hint to understand the negation handling of the query
language.
Ciao
Peter Sch�tt
Re: Query Parser OR AND and NOT
Posted by Erick Erickson <er...@gmail.com>.
The query language is NOT pure boolean. Hoss wrote this up:
http://searchhub.org/2011/12/28/why-not-and-or-and-not/
Best
Erick
On Mon, Apr 15, 2013 at 12:54 PM, Roman Chyla <ro...@gmail.com> wrote:
> Oh, sorry, I have assumed lucene query parser. I think SOLR qp must be
> different then, because for me it works as expected (our qp parser is
> identical with lucene in the way it treats modifiers +/- and operators
> AND/OR/NOT -- NOT must be joining two clauses: a NOT b, the first cannot be
> negative, as Chris points out; the modifier however can be first - but it
> cannot be alone, there must be at least one positive clause). Otherwise,
> -field:x it is changed into field:x
>
> http://labs.adsabs.harvard.edu/adsabs/search/?q=%28*+-abstract%3Ablack%29+AND+abstract%3Ahole*&db_key=ASTRONOMY&sort_type=DATE
> http://labs.adsabs.harvard.edu/adsabs/search/?q=%28-abstract%3Ablack%29+AND+abstract%3Ahole*&db_key=ASTRONOMY&sort_type=DATE
>
> roman
>
>
> On Mon, Apr 15, 2013 at 12:25 PM, Peter Schütt <ne...@pstt.de> wrote:
>
>> Hallo,
>>
>>
>> Roman Chyla <ro...@gmail.com> wrote in
>> news:CAEN8dyWjRL+E3B0HpC9NTLmJTrKASRQLVKZhKqXopMLHHFnJQQ@mail.gmail.com:
>>
>> > should be: -city:H* OR zip:30*
>> >
>> -city:H* OR zip:30* numFound:2520
>>
>> gives the same wrong result.
>>
>>
>> Another Idea?
>>
>> Ciao
>> Peter Schütt
>>
>>
>>
Re: Query Parser OR AND and NOT
Posted by Roman Chyla <ro...@gmail.com>.
Oh, sorry, I have assumed lucene query parser. I think SOLR qp must be
different then, because for me it works as expected (our qp parser is
identical with lucene in the way it treats modifiers +/- and operators
AND/OR/NOT -- NOT must be joining two clauses: a NOT b, the first cannot be
negative, as Chris points out; the modifier however can be first - but it
cannot be alone, there must be at least one positive clause). Otherwise,
-field:x it is changed into field:x
http://labs.adsabs.harvard.edu/adsabs/search/?q=%28*+-abstract%3Ablack%29+AND+abstract%3Ahole*&db_key=ASTRONOMY&sort_type=DATE
http://labs.adsabs.harvard.edu/adsabs/search/?q=%28-abstract%3Ablack%29+AND+abstract%3Ahole*&db_key=ASTRONOMY&sort_type=DATE
roman
On Mon, Apr 15, 2013 at 12:25 PM, Peter Schütt <ne...@pstt.de> wrote:
> Hallo,
>
>
> Roman Chyla <ro...@gmail.com> wrote in
> news:CAEN8dyWjRL+E3B0HpC9NTLmJTrKASRQLVKZhKqXopMLHHFnJQQ@mail.gmail.com:
>
> > should be: -city:H* OR zip:30*
> >
> -city:H* OR zip:30* numFound:2520
>
> gives the same wrong result.
>
>
> Another Idea?
>
> Ciao
> Peter Schütt
>
>
>
Re: Query Parser OR AND and NOT
Posted by Luis Lebolo <lu...@gmail.com>.
What if you try
city:(*:* -H*) OR zip:30*
Sometimes Solr requires a list of documents to subtract from (think of "*:*
-someQuery" converts to "all documents without someQuery").
You can also try looking at your query with debugQuery = true.
-Luis
On Mon, Apr 15, 2013 at 12:25 PM, Peter Schütt <ne...@pstt.de> wrote:
> Hallo,
>
>
> Roman Chyla <ro...@gmail.com> wrote in
> news:CAEN8dyWjRL+E3B0HpC9NTLmJTrKASRQLVKZhKqXopMLHHFnJQQ@mail.gmail.com:
>
> > should be: -city:H* OR zip:30*
> >
> -city:H* OR zip:30* numFound:2520
>
> gives the same wrong result.
>
>
> Another Idea?
>
> Ciao
> Peter Schütt
>
>
>
Re: Query Parser OR AND and NOT
Posted by Peter Sch�tt <ne...@pstt.de>.
Hallo,
Roman Chyla <ro...@gmail.com> wrote in
news:CAEN8dyWjRL+E3B0HpC9NTLmJTrKASRQLVKZhKqXopMLHHFnJQQ@mail.gmail.com:
> should be: -city:H* OR zip:30*
>
-city:H* OR zip:30* numFound:2520
gives the same wrong result.
Another Idea?
Ciao
Peter Sch�tt
Re: Query Parser OR AND and NOT
Posted by Roman Chyla <ro...@gmail.com>.
should be: -city:H* OR zip:30*
On Mon, Apr 15, 2013 at 12:03 PM, Peter Schütt <ne...@pstt.de> wrote:
> Hallo,
> I do not really understand the query language of the SOLR-Queryparser.
>
> I use SOLR 4.2 und I have nearly 200000 sample address records in the
> SOLR-Database.
>
> I only use the "q" field in the SOLR Admin Web GUI and every other
> controls on this website is on default.
>
>
> First category:
>
> zip:30* numFound=2896
>
> city:H* OR zip:30* numFound=12519
>
> city:H* AND zip:30* numFound=376
>
> These results seems to me correct.
>
> Now I tried with negations:
>
> !city:H* numFound:194577 (seems to be correct)
>
> !city:H* AND zip:30* numFound:2520 (seems to be correct)
>
>
> !city:H* OR zip:30* numFound:2520 (!! this is wrong !!)
>
> Or do I do not understand something?
>
>
> (!city:H*) OR zip:30* numFound: 2896
>
> This is also wrong.
>
> Thanks for any hint to understand the negation handling of the query
> language.
>
> Ciao
> Peter Schütt
>
>
>
>
>
Re: Query Parser OR AND and NOT
Posted by Chris Hostetter <ho...@fucit.org>.
: Hallo,
: I do not really understand the query language of the SOLR-Queryparser.
http://www.lucidimagination.com/blog/2011/12/28/why-not-and-or-and-not/
The one comment i would add regarding your specific examples...
: (!city:H*) OR zip:30* numFound: 2896
...you can't have a boolean query -- the parens -- containing purely
negative clauses like. that boolean query doesn't match anything, just
just explcudes things. If the *entire* query is negative, then solr helps
you out by implicitly making the negation relative to a query that matches
all documents, but if you are creating boolean sub-queries with parens,
then you need something "positive" in that sub-query to match some
criteria X and then your negations provide exclusions from that criteria.
-Hoss