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 Gregg Donovan <gr...@gmail.com> on 2014/02/18 20:32:53 UTC

Caching Solr boost functions?

We're testing out a new handler that uses edismax with three different
"boost" functions. One has a random() function in it, so is not very
cacheable, but the other two boost functions do not change from query to
query.

I'd like to tell Solr to cache those boost queries for the life of the
Searcher so they don't get recomputed every time. Is there any way to do
that out of the box?

In a different custom QParser we have we wrote a CachingValueSource that
wrapped a ValueSource with a custom ValueSource cache. Would it make sense
to implement that as a standard Solr function so that one could do:

boost=cache(expensiveFunctionQuery())

Thanks.

--Gregg

Re: Caching Solr boost functions?

Posted by Jason Hellman <jh...@innoventsolutions.com>.
Gregg,

The QueryResultCache caches a sorted int array of results matching the a query.  This should overlap very nicely with your desired behavior, as a hit in this cache will not perform a Lucene query nor a need to calculate score.  

Now, ‘for the life of the Searcher’ is the trick here.  You can size your cache large enough to ensure it can fit every possible query, but at some point this is untenable.  I would argue that high volatility of query parameters would invalidate the need for caching anyway, but that’s clearly debatable.  Nevertheless, this should work admirably well to solve your needs.

Jason

On Feb 18, 2014, at 11:32 AM, Gregg Donovan <gr...@gmail.com> wrote:

> We're testing out a new handler that uses edismax with three different
> "boost" functions. One has a random() function in it, so is not very
> cacheable, but the other two boost functions do not change from query to
> query.
> 
> I'd like to tell Solr to cache those boost queries for the life of the
> Searcher so they don't get recomputed every time. Is there any way to do
> that out of the box?
> 
> In a different custom QParser we have we wrote a CachingValueSource that
> wrapped a ValueSource with a custom ValueSource cache. Would it make sense
> to implement that as a standard Solr function so that one could do:
> 
> boost=cache(expensiveFunctionQuery())
> 
> Thanks.
> 
> --Gregg


Re: Caching Solr boost functions?

Posted by Chris Hostetter <ho...@fucit.org>.
: I'd like to tell Solr to cache those boost queries for the life of the
: Searcher so they don't get recomputed every time. Is there any way to do
: that out of the box?

if the functions never change, you could just index the computed value up 
front and save cycles at query time -- but that's the only option i can 
think of off the top of my head.

: In a different custom QParser we have we wrote a CachingValueSource that
: wrapped a ValueSource with a custom ValueSource cache. Would it make sense
: to implement that as a standard Solr function so that one could do:
: 
: boost=cache(expensiveFunctionQuery())

Yeah... that could be handy.  Something like this perhaps?

  <cache name="some_cache_name"
         class="solr.LRUCache"
         size="4096"
         autowarmCount="1024"
         regenerator="solr.ValueSourceCacheRegenerator"
  />

  <valueSourceParser name="cache" class="solr.ValueSourceCachingParser">
    <str name="cacheName">some_cache_name</str>
  </valueSourceParser>



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