org.apache.solr.client.solrj.embedded

## Class EmbeddedSolrServer

- java.lang.Object
- - org.apache.solr.client.solrj.SolrClient
  - - org.apache.solr.client.solrj.embedded.EmbeddedSolrServer

- All Implemented Interfaces:
    Closeable, Serializable, AutoCloseable

      public class EmbeddedSolrServer
      extends SolrClient

  SolrClient that connects directly to a CoreContainer.
  Since:
    solr 1.3
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CoreContainer` | `coreContainer`
    `protected String` | `coreName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EmbeddedSolrServer(CoreContainer coreContainer, String coreName)` Create an EmbeddedSolrServer wrapping a CoreContainer.
    `EmbeddedSolrServer(NodeConfig nodeConfig, String defaultCoreName)` Create an EmbeddedSolrServer using a NodeConfig
    `EmbeddedSolrServer(Path solrHome, String defaultCoreName)` Create an EmbeddedSolrServer using a given solr home directory
    `EmbeddedSolrServer(SolrCore core)` Create an EmbeddedSolrServer wrapping a particular SolrCore

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Shutdown all cores within the EmbeddedSolrServer instance
    `CoreContainer` | `getCoreContainer()` Getter method for the CoreContainer
    `NamedList<Object>` | `request(SolrRequest request, String coreName)`

    - ### Methods inherited from class org.apache.solr.client.solrj.SolrClient

      `add, add, add, add, add, add, add, add, add, add, addBean, addBean, addBean, addBean, addBeans, addBeans, addBeans, addBeans, addBeans, addBeans, commit, commit, commit, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, deleteByQuery, deleteByQuery, getBinder, getById, getById, getById, getById, getById, getById, getById, getById, optimize, optimize, optimize, optimize, optimize, optimize, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### coreContainer

          protected final CoreContainer coreContainer

    - #### coreName

          protected final String coreName

  - ### Constructor Detail

    - #### EmbeddedSolrServer

          public EmbeddedSolrServer(Path solrHome,
                                    String defaultCoreName)

      Create an EmbeddedSolrServer using a given solr home directory
      Parameters:
        `solrHome` - the solr home directory
        `defaultCoreName` - the core to route requests to by default

    - #### EmbeddedSolrServer

          public EmbeddedSolrServer(NodeConfig nodeConfig,
                                    String defaultCoreName)

      Create an EmbeddedSolrServer using a NodeConfig
      Parameters:
        `nodeConfig` - the configuration
        `defaultCoreName` - the core to route requests to be default

    - #### EmbeddedSolrServer

          public EmbeddedSolrServer(SolrCore core)

      Create an EmbeddedSolrServer wrapping a particular SolrCore

    - #### EmbeddedSolrServer

          public EmbeddedSolrServer(CoreContainer coreContainer,
                                    String coreName)

      Create an EmbeddedSolrServer wrapping a CoreContainer.

      Note that EmbeddedSolrServer will shutdown the wrapped CoreContainer when `close()` is called.

      Parameters:
        `coreContainer` - the core container
        `coreName` - the core to route requests to be default

  - ### Method Detail

    - #### request

          public NamedList<Object> request(SolrRequest request,
                                           String coreName)
                                    throws SolrServerException,
                                           IOException

      Specified by:
        `request` in class `SolrClient`
      Throws:
        `SolrServerException`
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Shutdown all cores within the EmbeddedSolrServer instance
      Throws:
        `IOException`

    - #### getCoreContainer

          public CoreContainer getCoreContainer()

      Getter method for the CoreContainer
      Returns:
        the core container

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