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 Matteo Grolla <ma...@gmail.com> on 2016/07/28 07:36:52 UTC

matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Hi,
    I'm surprised by lucene query parser translating this query

http://localhost:8983/solr/collection1/select?df=id&q=*

in

<str name="parsedquery">MatchAllDocsQuery(*:*)</str>

I was expecting it to execute: "id:*"
is it a bug or a desired behaviour? If desired can you explain why?

Re: matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Posted by Chris Hostetter <ho...@fucit.org>.
: I'd argue that the behavior is incorrect. Could you raise a JIRA?

that behavior was intentionally added becaus most users kept getting 
really confused by the older default behavion (which was previously a 
0-length prefix against hte default search field)

	https://issues.apache.org/jira/browse/SOLR-2996

if you do in fact whant a 0-length prefix query against hte default search 
field...

* use the prefix parser:  q={!prefix f=$df v=''}
* use an explicit field name: q=yourDefaultField:*

...if you just want all fields that contain any terms in your default 
field, use the "fieldName:[* TO *]" range syntax (which should be more 
efficient ... although it's possible "fieldName:*" was also optimized to 
be as efficient ... i can't remember)




: Erick
: 
: On Thu, Jul 28, 2016 at 1:34 AM, Matteo Grolla <ma...@gmail.com> wrote:
: > Hi Alessandro,
: >      your shot in the dark was interesting, but the behaviour doesn't
: > depend on the field being mandatory, it works like this for every field. So
: > it seems just wrong
: >
: > df=field&q=*
: >
: > should be translated as field:*
: >
: > not as *:*
: >
: >
: > 2016-07-28 10:32 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
: >
: >> It seems a wanted behaviour (see code at the bottom),
: >>
: >> Still the behaviour seems wrong to me
: >>
: >>
: >> the field is not set explicity but in the df, so getExplicitField returns
: >> null
: >>
: >> // called from parser
: >> protected Query getWildcardQuery(String field, String termStr) throws SyntaxError {
: >>   checkNullField(field);
: >>   // *:* -> MatchAllDocsQuery
: >>   if ("*".equals(termStr)) {
: >>     if ("*".equals(field) || getExplicitField() == null) {
: >>       return newMatchAllDocsQuery();
: >>     }
: >>   }
: >>
: >>
: >> 2016-07-28 9:40 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
: >>
: >>> I noticed the behaviour in solr 4.10 and 5.4.1
: >>>
: >>> 2016-07-28 9:36 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
: >>>
: >>>> Hi,
: >>>>     I'm surprised by lucene query parser translating this query
: >>>>
: >>>> http://localhost:8983/solr/collection1/select?df=id&q=*
: >>>>
: >>>> in
: >>>>
: >>>> <str name="parsedquery">MatchAllDocsQuery(*:*)</str>
: >>>>
: >>>> I was expecting it to execute: "id:*"
: >>>> is it a bug or a desired behaviour? If desired can you explain why?
: >>>>
: >>>
: >>>
: >>
: 

-Hoss
http://www.lucidworks.com/

Re: matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Posted by Erick Erickson <er...@gmail.com>.
Matteo:

I'd argue that the behavior is incorrect. Could you raise a JIRA?

Erick

On Thu, Jul 28, 2016 at 1:34 AM, Matteo Grolla <ma...@gmail.com> wrote:
> Hi Alessandro,
>      your shot in the dark was interesting, but the behaviour doesn't
> depend on the field being mandatory, it works like this for every field. So
> it seems just wrong
>
> df=field&q=*
>
> should be translated as field:*
>
> not as *:*
>
>
> 2016-07-28 10:32 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>
>> It seems a wanted behaviour (see code at the bottom),
>>
>> Still the behaviour seems wrong to me
>>
>>
>> the field is not set explicity but in the df, so getExplicitField returns
>> null
>>
>> // called from parser
>> protected Query getWildcardQuery(String field, String termStr) throws SyntaxError {
>>   checkNullField(field);
>>   // *:* -> MatchAllDocsQuery
>>   if ("*".equals(termStr)) {
>>     if ("*".equals(field) || getExplicitField() == null) {
>>       return newMatchAllDocsQuery();
>>     }
>>   }
>>
>>
>> 2016-07-28 9:40 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>>
>>> I noticed the behaviour in solr 4.10 and 5.4.1
>>>
>>> 2016-07-28 9:36 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>>>
>>>> Hi,
>>>>     I'm surprised by lucene query parser translating this query
>>>>
>>>> http://localhost:8983/solr/collection1/select?df=id&q=*
>>>>
>>>> in
>>>>
>>>> <str name="parsedquery">MatchAllDocsQuery(*:*)</str>
>>>>
>>>> I was expecting it to execute: "id:*"
>>>> is it a bug or a desired behaviour? If desired can you explain why?
>>>>
>>>
>>>
>>

Re: matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Posted by Matteo Grolla <ma...@gmail.com>.
Hi Alessandro,
     your shot in the dark was interesting, but the behaviour doesn't
depend on the field being mandatory, it works like this for every field. So
it seems just wrong

df=field&q=*

should be translated as field:*

not as *:*


2016-07-28 10:32 GMT+02:00 Matteo Grolla <ma...@gmail.com>:

> It seems a wanted behaviour (see code at the bottom),
>
> Still the behaviour seems wrong to me
>
>
> the field is not set explicity but in the df, so getExplicitField returns
> null
>
> // called from parser
> protected Query getWildcardQuery(String field, String termStr) throws SyntaxError {
>   checkNullField(field);
>   // *:* -> MatchAllDocsQuery
>   if ("*".equals(termStr)) {
>     if ("*".equals(field) || getExplicitField() == null) {
>       return newMatchAllDocsQuery();
>     }
>   }
>
>
> 2016-07-28 9:40 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>
>> I noticed the behaviour in solr 4.10 and 5.4.1
>>
>> 2016-07-28 9:36 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>>
>>> Hi,
>>>     I'm surprised by lucene query parser translating this query
>>>
>>> http://localhost:8983/solr/collection1/select?df=id&q=*
>>>
>>> in
>>>
>>> <str name="parsedquery">MatchAllDocsQuery(*:*)</str>
>>>
>>> I was expecting it to execute: "id:*"
>>> is it a bug or a desired behaviour? If desired can you explain why?
>>>
>>
>>
>

Re: matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Posted by Matteo Grolla <ma...@gmail.com>.
It seems a wanted behaviour (see code at the bottom),

Still the behaviour seems wrong to me


the field is not set explicity but in the df, so getExplicitField returns
null

// called from parser
protected Query getWildcardQuery(String field, String termStr) throws
SyntaxError {
  checkNullField(field);
  // *:* -> MatchAllDocsQuery
  if ("*".equals(termStr)) {
    if ("*".equals(field) || getExplicitField() == null) {
      return newMatchAllDocsQuery();
    }
  }


2016-07-28 9:40 GMT+02:00 Matteo Grolla <ma...@gmail.com>:

> I noticed the behaviour in solr 4.10 and 5.4.1
>
> 2016-07-28 9:36 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>
>> Hi,
>>     I'm surprised by lucene query parser translating this query
>>
>> http://localhost:8983/solr/collection1/select?df=id&q=*
>>
>> in
>>
>> <str name="parsedquery">MatchAllDocsQuery(*:*)</str>
>>
>> I was expecting it to execute: "id:*"
>> is it a bug or a desired behaviour? If desired can you explain why?
>>
>
>

Re: matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Posted by Alessandro Benedetti <ab...@apache.org>.
Shot in the dark , is your id your uniqueKey ?
In the case, it is legit to parse the special matchAllDocsQuery as that
field is mandatory and unique.
So your high-level query is actually asking for all the documents in the
index.

I haven't checked in the code but if I remember well, that is a special
query specifically to fetch all the documents.
Different implementation from the normal wildcard queries.

What is your concern Matteo?

Cheers


On Thu, Jul 28, 2016 at 8:40 AM, Matteo Grolla <ma...@gmail.com>
wrote:

> I noticed the behaviour in solr 4.10 and 5.4.1
>
> 2016-07-28 9:36 GMT+02:00 Matteo Grolla <ma...@gmail.com>:
>
> > Hi,
> >     I'm surprised by lucene query parser translating this query
> >
> > http://localhost:8983/solr/collection1/select?df=id&q=*
> >
> > in
> >
> > <str name="parsedquery">MatchAllDocsQuery(*:*)</str>
> >
> > I was expecting it to execute: "id:*"
> > is it a bug or a desired behaviour? If desired can you explain why?
> >
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Re: matchAllDocsQuery instead of WildCardQuery from lucene qp with df and *

Posted by Matteo Grolla <ma...@gmail.com>.
I noticed the behaviour in solr 4.10 and 5.4.1

2016-07-28 9:36 GMT+02:00 Matteo Grolla <ma...@gmail.com>:

> Hi,
>     I'm surprised by lucene query parser translating this query
>
> http://localhost:8983/solr/collection1/select?df=id&q=*
>
> in
>
> <str name="parsedquery">MatchAllDocsQuery(*:*)</str>
>
> I was expecting it to execute: "id:*"
> is it a bug or a desired behaviour? If desired can you explain why?
>