SolrCore (Solr 3.6.2 API)
Keywords: org.apache.solr.core.SolrCore class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.core
Class SolrCore

    java.lang.Object
      org.apache.solr.core.SolrCore

All Implemented Interfaces:
  SolrInfoMBean

    public final class SolrCore

extends Object
implements SolrInfoMBean

Version:
  $Id: SolrCore.java 1305693 2012-03-27 00:43:47Z janhoy $

Nested Class Summary
`class` | `SolrCore.LazyQueryResponseWriterWrapper`

Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoMBean
`SolrInfoMBean.Category`

Field Summary
`static Map<String,QueryResponseWriter>` | `DEFAULT_RESPONSE_WRITERS`
`static org.slf4j.Logger` | `log`
`static String` | `version`

Constructor Summary
`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.

Method Summary
`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. Use `execute(SolrRequestHandler, SolrQueryRequest, SolrQueryResponse)` instead.
`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.
`
`<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)`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### version

    public static final String version

See Also:
  Constant Field Values

### log

    public static org.slf4j.Logger log

### DEFAULT_RESPONSE_WRITERS

    public static final Map<String,QueryResponseWriter> DEFAULT_RESPONSE_WRITERS

Constructor Detail

### SolrCore

    public SolrCore(String dataDir,
                    IndexSchema schema)
             throws ParserConfigurationException,
                    IOException,
                    SAXException

Parameters:
  `dataDir` -
  `schema` -
Throws:
  `SAXException`
  `IOException`
  `ParserConfigurationException`
Since:
  solr 1.0

### SolrCore

    public SolrCore(String name,
                    String dataDir,
                    SolrConfig config,
                    IndexSchema schema,
                    CoreDescriptor cd)

  Creates a new core and register it in the list of cores. If a core with the same name already exists, it will be stopped and replaced by this one.

  Parameters:
    `dataDir` - the index directory
    `config` - a solr config instance
    `schema` - a solr schema instance
  Since:
    solr 1.3

Method Detail

### getStartTime

    public long getStartTime()

### getResourceLoader

    public SolrResourceLoader getResourceLoader()

  The SolrResourceLoader used to load all resources for this core.

  Since:
    solr 1.3

### getConfigResource

    public String getConfigResource()

  Gets the configuration resource name used by this core instance.

  Since:
    solr 1.3

### getConfigFile

    @Deprecated
    public String getConfigFile()

  Deprecated. Use `getConfigResource()` instead.

  Gets the configuration resource name used by this core instance.

### getSolrConfig

    public SolrConfig getSolrConfig()

  Gets the configuration object used by this core instance.

### getSchemaResource

    public String getSchemaResource()

  Gets the schema resource name used by this core instance.

  Since:
    solr 1.3

### getSchemaFile

    @Deprecated
    public String getSchemaFile()

  Deprecated. Use `getSchemaResource()` instead.

  Gets the schema resource name used by this core instance.

### getSchema

    public IndexSchema getSchema()

  Gets the schema object used by this core instance.

### getDataDir

    public String getDataDir()

### getIndexDir

    public String getIndexDir()

### getNewIndexDir

    public String getNewIndexDir()

  Returns the indexdir as given in index.properties. If index.properties exists in dataDir and there is a property index available and it points to a valid directory in dataDir that is returned Else dataDir/index is returned. Only called for creating new indexSearchers and indexwriters. Use the getIndexDir() method to know the active index directory

  Returns:
    the indexdir as given in index.properties

### getDirectoryFactory

    public DirectoryFactory getDirectoryFactory()

### getIndexReaderFactory

    public IndexReaderFactory getIndexReaderFactory()

### getName

    public String getName()

  Description copied from interface: `SolrInfoMBean`
  Simple common usage name, e.g. BasicQueryHandler, or fully qualified clas name.

  Specified by:
    `getName` in interface `SolrInfoMBean`

### setName

    public void setName(String v)

### getLogId

    public String getLogId()

### getInfoRegistry

    public Map<String,SolrInfoMBean> getInfoRegistry()

  Returns a Map of name vs SolrInfoMBean objects. The returned map is an instance of a ConcurrentHashMap and therefore no synchronization is needed for putting, removing or iterating over it.

  Returns:
    the Info Registry map which contains SolrInfoMBean objects keyed by name
  Since:
    solr 1.3

### registerFirstSearcherListener

    public void registerFirstSearcherListener(SolrEventListener listener)

  NOTE: this function is not thread safe. However, it is safe to call within the `inform( SolrCore core )` function for `SolrCoreAware` classes. Outside `inform`, this could potentially throw a ConcurrentModificationException

  See Also:
    `SolrCoreAware`

### registerNewSearcherListener

    public void registerNewSearcherListener(SolrEventListener listener)

  NOTE: this function is not thread safe. However, it is safe to call within the `inform( SolrCore core )` function for `SolrCoreAware` classes. Outside `inform`, this could potentially throw a ConcurrentModificationException

  See Also:
    `SolrCoreAware`

### registerResponseWriter

    public QueryResponseWriter registerResponseWriter(String name,
                                                      QueryResponseWriter responseWriter)

  NOTE: this function is not thread safe. However, it is safe to call within the `inform( SolrCore core )` function for `SolrCoreAware` classes. Outside `inform`, this could potentially throw a ConcurrentModificationException

  See Also:
    `SolrCoreAware`

### newSearcher

    public SolrIndexSearcher newSearcher(String name)
                                  throws IOException

  Throws:
    `IOException`

### newSearcher

    public SolrIndexSearcher newSearcher(String name,
                                         boolean readOnly)
                                  throws IOException

  Throws:
    `IOException`

### createInitInstance

    public <T> T createInitInstance(PluginInfo info,
                                    Class<T> cast,
                                    String msg,
                                    String defClassName)

### createEventListener

    public SolrEventListener createEventListener(String className)

### createRequestHandler

    public SolrRequestHandler createRequestHandler(String className)

### getSolrCore

    @Deprecated
    public static SolrCore getSolrCore()

  Deprecated. Use `CoreContainer.getCore(String)` instead.

  Returns:
    the last core initialized. If you are using multiple cores, this is not a function to use.

### getUpdateProcessingChain

    public UpdateRequestProcessorChain getUpdateProcessingChain(String name)

  Returns:
    an update processor registered to the given name. Throw an exception if this chain is undefined

### close

    public void close()

  Close all resources allocated by the core if it is no longer in use...
  - searcher
  - updateHandler
  - all CloseHooks will be notified
  - All MBeans will be unregistered from MBeanServer if JMX was enabled

  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)...

  - If reference count is > 0, the usage count is decreased by 1 and no resources are released.
  - If reference count is == 0, the resources are released.
  - If reference count is < 0, and error is logged and no further action is taken.

  See Also:
    `isClosed()`

### getOpenCount

    public int getOpenCount()

  Current core usage count.

### isClosed

    public boolean isClosed()

  Whether this core is closed.

### finalize

    protected void finalize()
                     throws Throwable

  Overrides:
    `finalize` in class `Object`
  Throws:
    `Throwable`

### addCloseHook

    public void addCloseHook(CloseHook hook)

  Add a close callback hook

### getPingQueryRequest

    @Deprecated
    public SolrQueryRequest getPingQueryRequest()

  Deprecated. use `PingRequestHandler` instead

  Returns a Request object based on the admin/pingQuery section of the Solr config file.

### getRequestHandler

    public SolrRequestHandler getRequestHandler(String handlerName)

  Get the request handler registered to a given name. This function is thread safe.

### getRequestHandlers

    public Map<String,SolrRequestHandler> getRequestHandlers(Class clazz)

  Returns an unmodifieable Map containing the registered handlers of the specified type.

### getRequestHandlers

    public Map<String,SolrRequestHandler> getRequestHandlers()

  Returns an unmodifieable Map containing the registered handlers

### getHighlighter

    @Deprecated
    public SolrHighlighter getHighlighter()

  Deprecated.

  Get the SolrHighlighter

### registerRequestHandler

    public SolrRequestHandler registerRequestHandler(String handlerName,
                                                     SolrRequestHandler handler)

  Registers a handler at the specified location. If one exists there, it will be replaced. To remove a handler, register `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.

  Returns:
    the previous `SolrRequestHandler` registered to this name `null` if none.

### getSearchComponent

    public SearchComponent getSearchComponent(String name)

  Returns:
    a Search Component registered to a given name. Throw an exception if the component is undefined

### getSearchComponents

    public Map<String,SearchComponent> getSearchComponents()

  Accessor for all the Search Components

  Returns:
    An unmodifiable Map of Search Components

### getUpdateHandler

    public UpdateHandler getUpdateHandler()

  RequestHandlers need access to the updateHandler so they can all talk to the same RAM indexer.

### getSearcher

    public RefCounted<SolrIndexSearcher> getSearcher()

  Return a registered `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.

### getNewestSearcher

    public RefCounted<SolrIndexSearcher> getNewestSearcher(boolean openNew)

  Return the newest `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.

### getSearcher

    public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew,
                                                     boolean returnSearcher,
                                                     Future[] waitSearcher)
                                              throws IOException

  Get a `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 a searcher is already registered, that searcher will be returned
  - If no searcher is currently registered, but at least one is in the process of being created, then this call will block until the first searcher is registered
  - If no searcher is currently registered, and no searchers in the process of being registered, a new searcher will be created.

  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.

  Parameters:
    `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.
  Throws:
    `IOException`

### closeSearcher

    public void closeSearcher()

### execute

    public void execute(SolrRequestHandler handler,
                        SolrQueryRequest req,
                        SolrQueryResponse rsp)

### execute

    @Deprecated
    public void execute(SolrQueryRequest req,
                                   SolrQueryResponse rsp)

  Deprecated. Use `execute(SolrRequestHandler, SolrQueryRequest, SolrQueryResponse)` instead.

### setResponseHeaderValues

    public static void setResponseHeaderValues(SolrRequestHandler handler,
                                               SolrQueryRequest req,
                                               SolrQueryResponse rsp)

### log

    public static final void log(Throwable e)

### getQueryResponseWriter

    public final QueryResponseWriter getQueryResponseWriter(String writerName)

  Finds a writer by name, or returns the default writer if not found.

### getQueryResponseWriter

    public final QueryResponseWriter getQueryResponseWriter(SolrQueryRequest request)

  Returns the appropriate writer for a request. If the request specifies a writer via the 'wt' parameter, attempts to find that one; otherwise return the default writer.

### getQueryPlugin

    public QParserPlugin getQueryPlugin(String parserName)

### initPlugins

    public <T> T initPlugins(Map<String,T> registry,
                             Class<T> type,
                             String defClassName)

  Parameters:
    `registry` - The map to which the instance should be added to. The key is the name attribute
    `type` - the class or interface that the instance should extend or implement.
    `defClassName` - If PluginInfo does not have a classname, use this as the classname
  Returns:
    The default instance . The one with (default=true)

### initPlugins

    public <T> T initPlugins(List<PluginInfo> pluginInfos,
                             Map<String,T> registry,
                             Class<T> type,
                             String defClassName)

### initPlugins

    public <T> List<T> initPlugins(List<PluginInfo> pluginInfos,
                                   Class<T> type,
                                   String defClassName)

  For a given List of PluginInfo return the instances as a List

  Parameters:
    `defClassName` - The default classname if PluginInfo#className == null
  Returns:
    The instances initialized

### initPlugins

    public <T> T initPlugins(Map<String,T> registry,
                             Class<T> type)

  Parameters:
    `registry` - The map to which the instance should be added to. The key is the name attribute
    `type` - The type of the Plugin. These should be standard ones registerd by type.getName() in SolrConfig
  Returns:
    The default if any

### getValueSourceParser

    public ValueSourceParser getValueSourceParser(String parserName)

### getCoreDescriptor

    public CoreDescriptor getCoreDescriptor()

### getDeletionPolicy

    public IndexDeletionPolicyWrapper getDeletionPolicy()

### getVersion

    public String getVersion()

  Description copied from interface: `SolrInfoMBean`
  Simple common usage version, e.g. 2.0

  Specified by:
    `getVersion` in interface `SolrInfoMBean`

### getDescription

    public String getDescription()

  Description copied from interface: `SolrInfoMBean`
  Simple one or two line description

  Specified by:
    `getDescription` in interface `SolrInfoMBean`

### getCategory

    public SolrInfoMBean.Category getCategory()

  Description copied from interface: `SolrInfoMBean`
  Purpose of this Class

  Specified by:
    `getCategory` in interface `SolrInfoMBean`

### getSourceId

    public String getSourceId()

  Description copied from interface: `SolrInfoMBean`
  CVS Id, SVN Id, etc

  Specified by:
    `getSourceId` in interface `SolrInfoMBean`

### getSource

    public String getSource()

  Description copied from interface: `SolrInfoMBean`
  CVS Source, SVN Source, etc

  Specified by:
    `getSource` in interface `SolrInfoMBean`

### getDocs

    public URL[] getDocs()

  Description copied from interface: `SolrInfoMBean`
  Documentation URL list.

  Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...

  Specified by:
    `getDocs` in interface `SolrInfoMBean`

### getStatistics

    public NamedList getStatistics()

  Description copied from interface: `SolrInfoMBean`
  Any statistics this instance would like to be publicly available via the Solr Administration interface.

  Any Object type may be stored in the list, but only the `toString()` representation will be used.

  Specified by:
    `getStatistics` in interface `SolrInfoMBean`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD