public final class SolrCore extends Object implements SolrInfoMBean
Modifier and Type | Class and Description |
---|---|
class |
SolrCore.LazyQueryResponseWriterWrapper |
SolrInfoMBean.Category
Modifier and Type | Field and Description |
---|---|
static Map<String,QueryResponseWriter> |
DEFAULT_RESPONSE_WRITERS |
static org.slf4j.Logger |
log |
static String |
version |
Constructor and Description |
---|
SolrCore(String dataDir,
IndexSchema schema) |
SolrCore(String name,
String dataDir,
SolrConfig config,
IndexSchema schema,
CoreDescriptor cd)
Creates a new core and register it in the list of cores.
|
Modifier and Type | Method and Description |
---|---|
void |
addCloseHook(CloseHook hook)
Add a close callback hook
|
void |
close()
Close all resources allocated by the core if it is no longer in use...
|
void |
closeSearcher() |
SolrEventListener |
createEventListener(String className) |
<T> T |
createInitInstance(PluginInfo info,
Class<T> cast,
String msg,
String defClassName) |
SolrRequestHandler |
createRequestHandler(String className) |
void |
execute(SolrQueryRequest req,
SolrQueryResponse rsp)
Deprecated.
|
void |
execute(SolrRequestHandler handler,
SolrQueryRequest req,
SolrQueryResponse rsp) |
protected void |
finalize() |
SolrInfoMBean.Category |
getCategory()
Purpose of this Class
|
String |
getConfigFile()
Deprecated.
Use
getConfigResource() instead. |
String |
getConfigResource()
Gets the configuration resource name used by this core instance.
|
CoreDescriptor |
getCoreDescriptor() |
String |
getDataDir() |
IndexDeletionPolicyWrapper |
getDeletionPolicy() |
String |
getDescription()
Simple one or two line description
|
DirectoryFactory |
getDirectoryFactory() |
URL[] |
getDocs()
Documentation URL list.
|
SolrHighlighter |
getHighlighter()
Deprecated.
|
String |
getIndexDir() |
IndexReaderFactory |
getIndexReaderFactory() |
Map<String,SolrInfoMBean> |
getInfoRegistry()
Returns a Map of name vs SolrInfoMBean objects.
|
String |
getLogId() |
String |
getName()
Simple common usage name, e.g.
|
RefCounted<SolrIndexSearcher> |
getNewestSearcher(boolean openNew)
Return the newest
RefCounted <SolrIndexSearcher > with
the reference count incremented. |
String |
getNewIndexDir()
Returns the indexdir as given in index.properties.
|
int |
getOpenCount()
Current core usage count.
|
SolrQueryRequest |
getPingQueryRequest()
Deprecated.
use
PingRequestHandler instead |
QParserPlugin |
getQueryPlugin(String parserName) |
QueryResponseWriter |
getQueryResponseWriter(SolrQueryRequest request)
Returns the appropriate writer for a request.
|
QueryResponseWriter |
getQueryResponseWriter(String writerName)
Finds a writer by name, or returns the default writer if not found.
|
SolrRequestHandler |
getRequestHandler(String handlerName)
Get the request handler registered to a given name.
|
Map<String,SolrRequestHandler> |
getRequestHandlers()
Returns an unmodifieable Map containing the registered handlers
|
Map<String,SolrRequestHandler> |
getRequestHandlers(Class clazz)
Returns an unmodifieable Map containing the registered handlers of the specified type.
|
SolrResourceLoader |
getResourceLoader()
The SolrResourceLoader used to load all resources for this core.
|
IndexSchema |
getSchema()
Gets the schema object used by this core instance.
|
String |
getSchemaFile()
Deprecated.
Use
getSchemaResource() instead. |
String |
getSchemaResource()
Gets the schema resource name used by this core instance.
|
SearchComponent |
getSearchComponent(String name) |
Map<String,SearchComponent> |
getSearchComponents()
Accessor for all the Search Components
|
RefCounted<SolrIndexSearcher> |
getSearcher()
Return a registered
RefCounted <SolrIndexSearcher > with
the reference count incremented. |
RefCounted<SolrIndexSearcher> |
getSearcher(boolean forceNew,
boolean returnSearcher,
Future[] waitSearcher)
Get a
SolrIndexSearcher or start the process of creating a new one. |
SolrConfig |
getSolrConfig()
Gets the configuration object used by this core instance.
|
static SolrCore |
getSolrCore()
Deprecated.
Use
CoreContainer.getCore(String) instead. |
String |
getSource()
CVS Source, SVN Source, etc
|
String |
getSourceId()
CVS Id, SVN Id, etc
|
long |
getStartTime() |
NamedList |
getStatistics()
Any statistics this instance would like to be publicly available via
the Solr Administration interface.
|
UpdateHandler |
getUpdateHandler()
RequestHandlers need access to the updateHandler so they can all talk to the
same RAM indexer.
|
UpdateRequestProcessorChain |
getUpdateProcessingChain(String name) |
ValueSourceParser |
getValueSourceParser(String parserName) |
String |
getVersion()
Simple common usage version, e.g. 2.0
|
<T> List<T> |
initPlugins(List<PluginInfo> pluginInfos,
Class<T> type,
String defClassName)
For a given List of PluginInfo return the instances as a List
|
<T> T |
initPlugins(List<PluginInfo> pluginInfos,
Map<String,T> registry,
Class<T> type,
String defClassName) |
<T> T |
initPlugins(Map<String,T> registry,
Class<T> type) |
<T> T |
initPlugins(Map<String,T> registry,
Class<T> type,
String defClassName) |
boolean |
isClosed()
Whether this core is closed.
|
static void |
log(Throwable e) |
SolrIndexSearcher |
newSearcher(String name) |
SolrIndexSearcher |
newSearcher(String name,
boolean readOnly) |
void |
registerFirstSearcherListener(SolrEventListener listener)
NOTE: this function is not thread safe.
|
void |
registerNewSearcherListener(SolrEventListener listener)
NOTE: this function is not thread safe.
|
SolrRequestHandler |
registerRequestHandler(String handlerName,
SolrRequestHandler handler)
Registers a handler at the specified location.
|
QueryResponseWriter |
registerResponseWriter(String name,
QueryResponseWriter responseWriter)
NOTE: this function is not thread safe.
|
void |
setName(String v) |
static void |
setResponseHeaderValues(SolrRequestHandler handler,
SolrQueryRequest req,
SolrQueryResponse rsp) |
public static final String version
public static org.slf4j.Logger log
public static final Map<String,QueryResponseWriter> DEFAULT_RESPONSE_WRITERS
public SolrCore(String dataDir, IndexSchema schema) throws ParserConfigurationException, IOException, SAXException
dataDir
- schema
- SAXException
IOException
ParserConfigurationException
public SolrCore(String name, String dataDir, SolrConfig config, IndexSchema schema, CoreDescriptor cd)
dataDir
- the index directoryconfig
- a solr config instanceschema
- a solr schema instancepublic long getStartTime()
public SolrResourceLoader getResourceLoader()
public String getConfigResource()
@Deprecated public String getConfigFile()
getConfigResource()
instead.public SolrConfig getSolrConfig()
public String getSchemaResource()
@Deprecated public String getSchemaFile()
getSchemaResource()
instead.public IndexSchema getSchema()
public String getDataDir()
public String getIndexDir()
public String getNewIndexDir()
public DirectoryFactory getDirectoryFactory()
public IndexReaderFactory getIndexReaderFactory()
public String getName()
SolrInfoMBean
getName
in interface SolrInfoMBean
public void setName(String v)
public String getLogId()
public Map<String,SolrInfoMBean> getInfoRegistry()
public void registerFirstSearcherListener(SolrEventListener listener)
inform( SolrCore core )
function for SolrCoreAware
classes.
Outside inform
, this could potentially throw a ConcurrentModificationExceptionSolrCoreAware
public void registerNewSearcherListener(SolrEventListener listener)
inform( SolrCore core )
function for SolrCoreAware
classes.
Outside inform
, this could potentially throw a ConcurrentModificationExceptionSolrCoreAware
public QueryResponseWriter registerResponseWriter(String name, QueryResponseWriter responseWriter)
inform( SolrCore core )
function for SolrCoreAware
classes.
Outside inform
, this could potentially throw a ConcurrentModificationExceptionSolrCoreAware
public SolrIndexSearcher newSearcher(String name) throws IOException
IOException
public SolrIndexSearcher newSearcher(String name, boolean readOnly) throws IOException
IOException
public <T> T createInitInstance(PluginInfo info, Class<T> cast, String msg, String defClassName)
public SolrEventListener createEventListener(String className)
public SolrRequestHandler createRequestHandler(String className)
@Deprecated public static SolrCore getSolrCore()
CoreContainer.getCore(String)
instead.public UpdateRequestProcessorChain getUpdateProcessingChain(String name)
public void close()
The behavior of this method is determined by the result of decrementing the core's reference count (A core is created with a refrence count of 1)...
isClosed()
public int getOpenCount()
public boolean isClosed()
protected void finalize() throws Throwable
public void addCloseHook(CloseHook hook)
@Deprecated public SolrQueryRequest getPingQueryRequest()
PingRequestHandler
insteadpublic SolrRequestHandler getRequestHandler(String handlerName)
public Map<String,SolrRequestHandler> getRequestHandlers(Class clazz)
public Map<String,SolrRequestHandler> getRequestHandlers()
@Deprecated public SolrHighlighter getHighlighter()
public SolrRequestHandler registerRequestHandler(String handlerName, SolrRequestHandler handler)
null
at its path
Once registered the handler can be accessed through:
http://${host}:${port}/${context}/${handlerName} or: http://${host}:${port}/${context}/select?qt=${handlerName}Handlers must be initalized before getting registered. Registered handlers can immediatly accept requests. This call is thread safe.
SolrRequestHandler
registered to this name null
if none.public SearchComponent getSearchComponent(String name)
public Map<String,SearchComponent> getSearchComponents()
public UpdateHandler getUpdateHandler()
public RefCounted<SolrIndexSearcher> getSearcher()
RefCounted
<SolrIndexSearcher
> with
the reference count incremented. It must be decremented when no longer needed.
This method should not be called from SolrCoreAware.inform() since it can result
in a deadlock if useColdSearcher==false.
If handling a normal request, the searcher should be obtained from
SolrQueryRequest.getSearcher()
instead.public RefCounted<SolrIndexSearcher> getNewestSearcher(boolean openNew)
RefCounted
<SolrIndexSearcher
> with
the reference count incremented. It must be decremented when no longer needed.
If no searcher is currently open, then if openNew==true a new searcher will be opened,
or null is returned if openNew==false.public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, Future[] waitSearcher) throws IOException
SolrIndexSearcher
or start the process of creating a new one.
The registered searcher is the default searcher used to service queries. A searcher will normally be registered after all of the warming and event handlers (newSearcher or firstSearcher events) have run. In the case where there is no registered searcher, the newly created searcher will be registered before running the event handlers (a slow searcher is better than no searcher).
These searchers contain read-only IndexReaders. To access a non read-only IndexReader, see newSearcher(String name, boolean readOnly).
If forceNew==true then A new searcher will be opened and registered regardless of whether there is already a registered searcher or other searchers in the process of being created.
If forceNew==false then:
If returnSearcher==true then a RefCounted
<SolrIndexSearcher
> will be returned with
the reference count incremented. It must be decremented when no longer needed.
If waitSearcher!=null and a new SolrIndexSearcher
was created,
then it is filled in with a Future that will return after the searcher is registered. The Future may be set to
null in which case the SolrIndexSearcher created has already been registered at the time
this method returned.
forceNew
- if true, force the open of a new index searcher regardless if there is already one open.returnSearcher
- if true, returns a SolrIndexSearcher
holder with the refcount already incremented.waitSearcher
- if non-null, will be filled in with a Future
that will return after the new searcher is registered.IOException
public void closeSearcher()
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp)
@Deprecated public void execute(SolrQueryRequest req, SolrQueryResponse rsp)
execute(SolrRequestHandler, SolrQueryRequest, SolrQueryResponse)
instead.public static void setResponseHeaderValues(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp)
public static final void log(Throwable e)
public final QueryResponseWriter getQueryResponseWriter(String writerName)
public final QueryResponseWriter getQueryResponseWriter(SolrQueryRequest request)
public QParserPlugin getQueryPlugin(String parserName)
public <T> T initPlugins(Map<String,T> registry, Class<T> type, String defClassName)
registry
- The map to which the instance should be added to. The key is the name attributetype
- the class or interface that the instance should extend or implement.defClassName
- If PluginInfo does not have a classname, use this as the classnamepublic <T> T initPlugins(List<PluginInfo> pluginInfos, Map<String,T> registry, Class<T> type, String defClassName)
public <T> List<T> initPlugins(List<PluginInfo> pluginInfos, Class<T> type, String defClassName)
defClassName
- The default classname if PluginInfo#className == nullpublic <T> T initPlugins(Map<String,T> registry, Class<T> type)
registry
- The map to which the instance should be added to. The key is the name attributetype
- The type of the Plugin. These should be standard ones registerd by type.getName() in SolrConfigpublic ValueSourceParser getValueSourceParser(String parserName)
public CoreDescriptor getCoreDescriptor()
public IndexDeletionPolicyWrapper getDeletionPolicy()
public String getVersion()
SolrInfoMBean
getVersion
in interface SolrInfoMBean
public String getDescription()
SolrInfoMBean
getDescription
in interface SolrInfoMBean
public SolrInfoMBean.Category getCategory()
SolrInfoMBean
getCategory
in interface SolrInfoMBean
public String getSourceId()
SolrInfoMBean
getSourceId
in interface SolrInfoMBean
public String getSource()
SolrInfoMBean
getSource
in interface SolrInfoMBean
public URL[] getDocs()
SolrInfoMBean
Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...
getDocs
in interface SolrInfoMBean
public NamedList getStatistics()
SolrInfoMBean
Any Object type may be stored in the list, but only the
toString()
representation will be used.
getStatistics
in interface SolrInfoMBean