You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Rahul Goswami <ra...@gmail.com> on 2021/03/23 18:51:56 UTC

Difference between * and [* TO *]

Hello,

Can someone please tell me what is the difference between q=myfield:* vs
q=myfield:[* TO *] for an indexed field "myfield". The available answers
online seem more like a best guess than a definitive answer, so I wanted to
get my understanding clarified. Also, my understanding is that myfield:[*
TO *] is more performant than myfield:* , is that correct?

Thanks,
Rahul

Re: Difference between * and [* TO *]

Posted by Houston Putman <ho...@gmail.com>.
So for a lot of fields, starting in 8.5 (SOLR-11746
<https://issues.apache.org/jira/browse/SOLR-11746>), the two are equivalent
and use the exact same, very fast (when possible), query mechanism. If you
are using Solr 8.4 or below, refer to Shawn's advice.

The difference between the two is documented in the Ref Guide
<https://solr.apache.org/guide/8_8/the-standard-query-parser.html#differences-between-lucenes-classic-query-parser-and-solrs-standard-query-parser>,
but they only differ for numeric fields which have NaN values.

- Housotn

On Tue, Mar 23, 2021 at 3:28 PM Shawn Heisey <ap...@elyograg.org> wrote:

> On 3/23/2021 12:51 PM, Rahul Goswami wrote:
> > Hello,
> >
> > Can someone please tell me what is the difference between q=myfield:* vs
> > q=myfield:[* TO *] for an indexed field "myfield". The available answers
> > online seem more like a best guess than a definitive answer, so I wanted
> to
> > get my understanding clarified. Also, my understanding is that myfield:[*
> > TO *] is more performant than myfield:* , is that correct?
>
> The first is a wildcard query.  The second is a range query.
>
> When you query myfield:* Lucene and Solr actually look up all possible
> terms in myfield and construct a huge query behind the scenes that
> contains all those terms.  If the field has millions or billions of
> terms, that is REALLY slow.  The memory allocations required to
> construct that query can result in additional slowdowns.
>
> In almost all cases, the range query is much faster.
>
> Thanks,
> Shawn
>

Re: Difference between * and [* TO *]

Posted by Shawn Heisey <ap...@elyograg.org>.
On 3/23/2021 12:51 PM, Rahul Goswami wrote:
> Hello,
> 
> Can someone please tell me what is the difference between q=myfield:* vs
> q=myfield:[* TO *] for an indexed field "myfield". The available answers
> online seem more like a best guess than a definitive answer, so I wanted to
> get my understanding clarified. Also, my understanding is that myfield:[*
> TO *] is more performant than myfield:* , is that correct?

The first is a wildcard query.  The second is a range query.

When you query myfield:* Lucene and Solr actually look up all possible 
terms in myfield and construct a huge query behind the scenes that 
contains all those terms.  If the field has millions or billions of 
terms, that is REALLY slow.  The memory allocations required to 
construct that query can result in additional slowdowns.

In almost all cases, the range query is much faster.

Thanks,
Shawn