Package org.apache.solr.schema
Class ExternalFileFieldReloader
- java.lang.Object
-
- org.apache.solr.core.AbstractSolrEventListener
-
- 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
Constructors Constructor Description ExternalFileFieldReloader(SolrCore core)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcacheFieldSources(IndexSchema schema)Caches FileFloatSource's from all ExternalFileField instances in the schemavoidinit(org.apache.solr.common.util.NamedList<?> args)initwill be called just once, immediately after creation.voidnewSearcher(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
-
-
-
-
Constructor Detail
-
ExternalFileFieldReloader
public ExternalFileFieldReloader(SolrCore core)
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugininitwill be called just once, immediately after creation.Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself
- Specified by:
initin interfaceNamedListInitializedPlugin- Overrides:
initin classAbstractSolrEventListener- Parameters:
args- non-null list of initialization parameters (may be empty)
-
newSearcher
public void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher)
Description copied from interface:SolrEventListenerThe 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.EVENTparameter and set it to a value of either:EventParams.FIRST_SEARCHER- First Searcher eventEventParams.NEW_SEARCHER- New Searcher event
if (currentSearcher != null) { nlst.add(CommonParams.EVENT, CommonParams.NEW_SEARCHER); } else { nlst.add(CommonParams.EVENT, CommonParams.FIRST_SEARCHER); }- Specified by:
newSearcherin interfaceSolrEventListener- Overrides:
newSearcherin classAbstractSolrEventListener- Parameters:
newSearcher- The newSolrIndexSearcherto usecurrentSearcher- The existingSolrIndexSearcher. 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
-
-