Package org.apache.solr.embedded
Class EmbeddedSolrBackend
java.lang.Object
org.apache.solr.embedded.EmbeddedSolrBackend
- All Implemented Interfaces:
AutoCloseable,SolrBackend
SolrBackend backed by an in-process CoreContainer/EmbeddedSolrServer. No
network or ZooKeeper overhead, although there's some request/response serialization.
Data is persisted in the given solrHome directory.
-
Constructor Summary
ConstructorsConstructorDescriptionEmbeddedSolrBackend(Path solrHome) EmbeddedSolrBackend(org.apache.solr.client.solrj.embedded.EmbeddedSolrServer solrServer) EmbeddedSolrBackend(org.apache.solr.core.CoreContainer container) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Shuts down this backend, releases the admin client, and all other resources.voidcreateCollection(org.apache.solr.client.solrj.request.CollectionAdminRequest.Create create) Creates a collection (or core for single-node backends).org.apache.solr.core.CoreContainerProvides access to an embedded/in-processCoreContainer-- if available (else null).org.apache.solr.client.solrj.embedded.EmbeddedSolrServerReturns the node / admin (collection-less)SolrClientowned by this backend.booleanhasCollection(String name) Checks if a collection or core with the given name exists.org.apache.solr.client.solrj.SolrClientnewSolrClient(String collection) Creates a newSolrClientdefaulted to the given collection.voidreloadCollection(String name) Reloads a collection or core by this name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.SolrBackend
dumpCoreInfo, dumpMetrics, getBaseUrl, hasConfigSet, uploadConfigSet
-
Constructor Details
-
EmbeddedSolrBackend
-
EmbeddedSolrBackend
public EmbeddedSolrBackend(org.apache.solr.client.solrj.embedded.EmbeddedSolrServer solrServer) - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
EmbeddedSolrBackend
public EmbeddedSolrBackend(org.apache.solr.core.CoreContainer container) - NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Method Details
-
getCoreContainer
public org.apache.solr.core.CoreContainer getCoreContainer()Description copied from interface:SolrBackendProvides access to an embedded/in-processCoreContainer-- if available (else null). If there is more than one node, then one is returned.- Specified by:
getCoreContainerin interfaceSolrBackend- Returns:
- can be null.
-
newSolrClient
Description copied from interface:SolrBackendCreates a newSolrClientdefaulted to the given collection. The caller owns this client and is responsible for closing it. Callers that want a long-lived client should cache it themselves.- Specified by:
newSolrClientin interfaceSolrBackend
-
getSolrClient
public org.apache.solr.client.solrj.embedded.EmbeddedSolrServer getSolrClient()Description copied from interface:SolrBackendReturns the node / admin (collection-less)SolrClientowned by this backend. The caller must NOT close it; it is released when this backend isSolrBackend.close()d. ACloudSolrClientshould be returned if appropriate. While it *can* be used to target specific collections, please useSolrBackend.newSolrClient(String)for that instead.- Specified by:
getSolrClientin interfaceSolrBackend
-
createCollection
public void createCollection(org.apache.solr.client.solrj.request.CollectionAdminRequest.Create create) Description copied from interface:SolrBackendCreates a collection (or core for single-node backends). Cloud backends honournumShardsandreplicationFactor; single-node backends (JettySolrRunner,EmbeddedSolrBackend) ignore those fields. Callers should useSolrBackend.hasCollection(String)first if they want to avoid errors when the collection already exists. Tests/benchmarks that want to test how this works should not use this to do so.- Specified by:
createCollectionin interfaceSolrBackend
-
hasCollection
Description copied from interface:SolrBackendChecks if a collection or core with the given name exists.- Specified by:
hasCollectionin interfaceSolrBackend- Parameters:
name- collection or core name to check- Returns:
- true if the collection/core exists, false otherwise
-
reloadCollection
Description copied from interface:SolrBackendReloads a collection or core by this name. The purpose is typically to clear caches.- Specified by:
reloadCollectionin interfaceSolrBackend- Throws:
org.apache.solr.common.SolrException
-
close
public void close()Description copied from interface:SolrBackendShuts down this backend, releases the admin client, and all other resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSolrBackend
-