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 void
cacheFieldSources(IndexSchema schema)
Caches FileFloatSource's from all ExternalFileField instances in the schemavoid
init(org.apache.solr.common.util.NamedList<?> args)
init
will be called just once, immediately after creation.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
-
-
-
-
Constructor Detail
-
ExternalFileFieldReloader
public ExternalFileFieldReloader(SolrCore core)
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugin
init
will 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:
init
in interfaceNamedListInitializedPlugin
- Overrides:
init
in classAbstractSolrEventListener
- Parameters:
args
- non-null list of initialization parameters (may be empty)
-
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: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:
newSearcher
in interfaceSolrEventListener
- Overrides:
newSearcher
in classAbstractSolrEventListener
- Parameters:
newSearcher
- The newSolrIndexSearcher
to 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
-
-