org.apache.solr.schema
Class ExternalFileFieldReloader

java.lang.Object
  extended by org.apache.solr.core.AbstractSolrEventListener
      extended by org.apache.solr.schema.ExternalFileFieldReloader
All Implemented Interfaces:
SolrEventListener, NamedListInitializedPlugin

public class ExternalFileFieldReloader
extends AbstractSolrEventListener

An event listener to reload ExternalFileFields for new searchers. Opening a new IndexSearcher will invalidate the internal caches used by ExternalFileField. By default, these caches are reloaded lazily by the first search that uses them. For large external files, this can slow down searches unacceptably. To reload the caches when the searcher is first opened, set up event listeners in your solrconfig.xml:

   <listener event="newSearcher" class="org.apache.solr.schema.ExternalFileFieldReloader"/>
   <listener event="firstSearcher" class="org.apache.solr.schema.ExternalFileFieldReloader"/>
 
The caches will be reloaded for all ExternalFileFields in your schema after each commit.


Constructor Summary
ExternalFileFieldReloader(SolrCore core)
           
 
Method Summary
 void cacheFieldSources(IndexSchema schema)
          Caches FileFloatSource's from all ExternalFileField instances in the schema
 void init(NamedList args)
           
 void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher)
          The searchers passed here are only guaranteed to be valid for the duration of this method call, so care should be taken not to spawn threads or asynchronous tasks with references to these searchers.
 
Methods inherited from class org.apache.solr.core.AbstractSolrEventListener
addEventParms, getArgs, getCore, postCommit, postSoftCommit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExternalFileFieldReloader

public ExternalFileFieldReloader(SolrCore core)
Method Detail

init

public void init(NamedList args)
Specified by:
init in interface NamedListInitializedPlugin
Overrides:
init in class AbstractSolrEventListener

newSearcher

public void newSearcher(SolrIndexSearcher newSearcher,
                        SolrIndexSearcher currentSearcher)
Description copied from interface: SolrEventListener
The searchers passed here are only guaranteed to be valid for the duration of this method call, so care should be taken not to spawn threads or asynchronous tasks with references to these searchers.

Implementations should add the EventParams.EVENT parameter and set it to a value of either:

Sample:
    if (currentSearcher != null) {
      nlst.add(CommonParams.EVENT, CommonParams.NEW_SEARCHER);
    } else {
      nlst.add(CommonParams.EVENT, CommonParams.FIRST_SEARCHER);
    }

 

Specified by:
newSearcher in interface SolrEventListener
Overrides:
newSearcher in class AbstractSolrEventListener
Parameters:
newSearcher - The new SolrIndexSearcher to use
currentSearcher - The existing SolrIndexSearcher. null if this is a firstSearcher event.
See Also:
AbstractSolrEventListener.addEventParms(org.apache.solr.search.SolrIndexSearcher, org.apache.solr.common.util.NamedList)

cacheFieldSources

public void cacheFieldSources(IndexSchema schema)
Caches FileFloatSource's from all ExternalFileField instances in the schema



Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.