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 oleole <ol...@gmail.com> on 2011/06/01 18:38:06 UTC

best way to update custom fieldcache after index commit?

Hi,

We use solr and lucene fieldcache like this
static DocTerms myfieldvalues =
org.apache.lucene.search.FieldCache.DEFAULT.getTerms(reader, "myField");
which is initialized at first use and will stay in memory for fast retrieval
of field values based on DocID

The problem is after an index/commit, the lucene fieldcache is reloaded in
the new searcher, but this static list need to updated as well,  what is the
best way to handle this? Basically we want to update those custom filedcache
whenever there is a commit. The possible solution I can think of:

1) manually call an request handler to clean up those custom stuffs after
commit, which is a hack and ugly.
2) use some listener event (not sure whether I can use newSearcher event
listener in Solr); also there seems to be a lucene ticket (
https://issues.apache.org/jira/browse/LUCENE-2474, Allow to plug in a Cache
Eviction Listener to IndexReader to eagerly clean custom caches that use the
IndexReader (getFieldCacheKey)), not clear to me how to use it though

Any of your suggestion/comments is much appreciated. Thanks!

oleole

Re: best way to update custom fieldcache after index commit?

Posted by Erick Erickson <er...@gmail.com>.
How are you implementing your custom cache? If you're defining
it in the solrconfig, couldn't you implement the regenerator? See:
http://wiki.apache.org/solr/SolrCaching#User.2BAC8-Generic_Caches

Best
Erick

On Wed, Jun 1, 2011 at 12:38 PM, oleole <ol...@gmail.com> wrote:
> Hi,
>
> We use solr and lucene fieldcache like this
> static DocTerms myfieldvalues =
> org.apache.lucene.search.FieldCache.DEFAULT.getTerms(reader, "myField");
> which is initialized at first use and will stay in memory for fast retrieval
> of field values based on DocID
>
> The problem is after an index/commit, the lucene fieldcache is reloaded in
> the new searcher, but this static list need to updated as well,  what is the
> best way to handle this? Basically we want to update those custom filedcache
> whenever there is a commit. The possible solution I can think of:
>
> 1) manually call an request handler to clean up those custom stuffs after
> commit, which is a hack and ugly.
> 2) use some listener event (not sure whether I can use newSearcher event
> listener in Solr); also there seems to be a lucene ticket (
> https://issues.apache.org/jira/browse/LUCENE-2474, Allow to plug in a Cache
> Eviction Listener to IndexReader to eagerly clean custom caches that use the
> IndexReader (getFieldCacheKey)), not clear to me how to use it though
>
> Any of your suggestion/comments is much appreciated. Thanks!
>
> oleole
>