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 maustin75 <ma...@gmail.com> on 2006/05/31 00:34:11 UTC

Range vs Term lookup

I'm doing a search based on price and was wondering what the performance 
difference would be between these two queries:

1) +price:[0 TO 20]
2) +price:4567

Basically, to do a search with a range or pre-determine the range and do a 
search based on an id?  It would be easier to set up with a range, however I 
don't want to lose performance.

Thanks,
Mike


Re: Range vs Term lookup

Posted by Yonik Seeley <ys...@gmail.com>.
On 5/30/06, maustin75 <ma...@gmail.com> wrote:
> > The same speed if they are in Solr's cache :-)
> > Range query will be slightly slower, but if it becomes a bottleneck or
> > not depends on the total complexity of the queries/requests.
>
> What does the cache use as a key to determine if it is cached?
>
> For example, how many bitsets are cached here with these to searches?
>
> "+id:test1 +id:test2"
> and.
> "+id:test2 +id:test1"

The Query acts as the cache key.
There is currently no normalization done to make "a AND b" equiv to "b AND a".
This often isn't much of a problem for programatically generated
queries since they are generated the same way each time.

> Does solr parse and cache each queryitem or the entire search query?

The entire query, filter, and sort acts as the cache key into the
queryResult cache.  The results of that query aren't fully cached
though, only a subset.

Here is the relevant portion of solrconfig.xml:
   <!-- An optimization for use with the queryResultCache.  When a search
         is requested, a superset of the requested number of document ids
         are collected.  For example, of a search for a particular query
         requests matching documents 10 through 19, and queryWindowSize is 50,
         then documents 0 through 50 will be collected and cached.  Any further
         requests in that range can be satisfied via the cache.  -->
    <queryResultWindowSize>10</queryResultWindowSize>


-Yonik

Re: Range vs Term lookup

Posted by maustin75 <ma...@gmail.com>.
> The same speed if they are in Solr's cache :-)
> Range query will be slightly slower, but if it becomes a bottleneck or
> not depends on the total complexity of the queries/requests.

What does the cache use as a key to determine if it is cached? 

For example, how many bitsets are cached here with these to searches?

"+id:test1 +id:test2"
and. 
"+id:test2 +id:test1"


Does solr parse and cache each queryitem or the entire search query?

> Start with the more flexible range query and only optimize if
> necessary.  Both should be relatively quick.

Yeah.. I think that is what I will do.

Re: Range vs Term lookup

Posted by Yonik Seeley <ys...@gmail.com>.
On 5/30/06, maustin75 <ma...@gmail.com> wrote:
> I'm doing a search based on price and was wondering what the performance
> difference would be between these two queries:
>
> 1) +price:[0 TO 20]
> 2) +price:4567
>
> Basically, to do a search with a range or pre-determine the range and do a
> search based on an id?

The same speed if they are in Solr's cache :-)
Range query will be slightly slower, but if it becomes a bottleneck or
not depends on the total complexity of the queries/requests.

> It would be easier to set up with a range, however I
> don't want to lose performance.

Start with the more flexible range query and only optimize if
necessary.  Both should be relatively quick.

-Yonik