Class SolrConfiguration
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
Provides a class that will statically hold the Solr server.
This is initialized in SolrSearchServiceImpl and used in SolrIndexServiceImpl
- Author:
- Andre Azzolini (apazzolini)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.solr.client.solrj.SolrClientprotected Stringprotected Stringprotected org.apache.solr.client.solrj.SolrClientprotected Stringprotected org.apache.solr.client.solrj.SolrClientprotected Stringprotected Stringprotected booleanprotected Stringprotected Integerprotected Integerprotected String -
Constructor Summary
ConstructorsConstructorDescriptionSolrConfiguration(org.apache.solr.client.solrj.impl.CloudSolrClient solrServer, org.apache.solr.client.solrj.impl.CloudSolrClient reindexServer, String solrCloudConfigName, int solrCloudNumShards, int replicationFactor) SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, String solrCloudConfigName, int solrCloudNumShards) This constructor should be used to set up Solr Cloud using solr cloud config name, number of cloud shards, and multiple clients, one primary, and one for reindexing to reduce down time during indexing.SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, String solrCloudConfigName, int solrCloudNumShards, String namespace) This constructor should be used to set up Solr Cloud using solr cloud config name, number of cloud shards, and multiple clients, one primary, and one for reindexing to reduce down time during indexing.SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer) Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing.SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer, String namespace) Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing.SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer, String primaryCoreName, String reindexCoreName) Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing.SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer, String primaryCoreName, String reindexCoreName, String namespace) Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing. -
Method Summary
Modifier and TypeMethodDescriptionvoidaliasCollectionMap(org.apache.solr.client.solrj.impl.CloudSolrClient client) protected voidcreateAlias(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName, String aliasName) protected voidcreateAliasIfNotExist(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName, String aliasName) protected voidcreateCollection(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName) protected voidcreateCollectionIfNotExist(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName) voiddestroy()protected StringdetermineCoreName(org.apache.solr.client.solrj.impl.HttpSolrClient httpSolrClient) org.apache.solr.client.solrj.SolrClientThe adminServer is just a reference to a SolrClient component for connecting to Solr.org.apache.solr.client.solrj.SolrClientorg.apache.solr.client.solrj.SolrClientprotected Stringprotected StringgetSiteAliasName(Site site) protected Stringprotected StringgetSiteCollectionName(Site site) protected StringgetSiteReindexAliasName(Site site) protected Stringorg.apache.solr.client.solrj.SolrClientorg.apache.solr.client.solrj.SolrClientbooleanbooleanbooleanprotected voidreloadCollectionNames(org.apache.solr.client.solrj.impl.CloudSolrClient primary, org.apache.solr.client.solrj.impl.CloudSolrClient reindex) voidsetAdminServer(org.apache.solr.client.solrj.SolrClient server) Sets the admin SolrClient instance to communicate with Solr for administrative reasons, like swapping cores.voidsetNamespace(String namespace) voidsetPrimaryName(String primaryName) voidsetReindexName(String reindex) voidsetReindexServer(org.apache.solr.client.solrj.SolrClient server) Sets the SolrClient instance that points to the reindex core for the purpose of doing a full reindex, while the primary core is still serving serving requests.voidsetServer(org.apache.solr.client.solrj.SolrClient server) Sets the primary SolrClient instance to communicate with Solr.voidsetSiteAliasBase(String siteAliasBase) voidsetSiteCollectionBase(String siteCollectionBase) voidsetSiteCollections(boolean siteCollections) voidsetSolrCloudConfigName(String solrCloudConfigName) voidsetSolrCloudNumReplicas(Integer solrCloudNumReplicas) voidsetSolrCloudNumShards(int solrCloudNumShards) voidsetSolrCloudNumShards(Integer solrCloudNumShards) voidsetSolrHomePath(String solrHomePath) protected StringsolrCloudConfigName(org.apache.solr.client.solrj.impl.CloudSolrClient client) protected voidvalidateCloudSolrClients(org.apache.solr.client.solrj.impl.CloudSolrClient primary, org.apache.solr.client.solrj.impl.CloudSolrClient reindex)
-
Field Details
-
-
reindexName
-
namespace
-
adminServer
protected org.apache.solr.client.solrj.SolrClient adminServer -
primaryServer
protected org.apache.solr.client.solrj.SolrClient primaryServer -
reindexServer
protected org.apache.solr.client.solrj.SolrClient reindexServer -
solrCloudConfigName
-
solrCloudNumShards
-
solrCloudNumReplicas
-
solrHomePath
-
siteCollections
@Value("${solr.index.site.collections:false}") protected boolean siteCollections -
siteAliasBase
-
siteCollectionBase
-
-
Constructor Details
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer) throws IllegalStateException Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing. This constructor should be used when setting up HttpSolrClient since no collection names are being provided.The adminServer is just a reference to a SolrClient component for connecting to Solr. In newer versions of Solr, 4.4 and beyond, auto discovery of cores is provided. When using a stand-alone server or server cluster, the admin server, for swapping cores, is a different URL. For example, one needs to use http://solrserver:8983/solr, which formerly acted as the admin server AND as the primary core. As of Solr 4.4, one needs to specify the cores separately: http://solrserver:8983/solr/primary and http://solrserver:8983/solr/reindex, and use http://solrserver:8983/solr for swapping cores.
- Parameters:
solrServer-reindexServer-adminServer-- Throws:
IllegalStateException
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer, String namespace) throws IllegalStateException Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing. This constructor should be used when setting up HttpSolrClient since no collection names are being provided. Namespace can be specified if managing multiple document sets within the same cores.The adminServer is just a reference to a SolrClient component for connecting to Solr. In newer versions of Solr, 4.4 and beyond, auto discovery of cores is provided. When using a stand-alone server or server cluster, the admin server, for swapping cores, is a different URL. For example, one needs to use http://solrserver:8983/solr, which formerly acted as the admin server AND as the primary core. As of Solr 4.4, one needs to specify the cores separately: http://solrserver:8983/solr/primary and http://solrserver:8983/solr/reindex, and use http://solrserver:8983/solr for swapping cores.
- Parameters:
solrServer-reindexServer-adminServer-namespace-- Throws:
IllegalStateException
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer, String primaryCoreName, String reindexCoreName) throws IllegalStateException Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing. This constructor should be used when setting up LBHttpSolrClients because primaryCoreName and reindexCoreName need to be provided to SolrConfiguration.The adminServer is just a reference to a SolrClient component for connecting to Solr. In newer versions of Solr, 4.4 and beyond, auto discovery of cores is provided. When using a stand-alone server or server cluster, the admin server, for swapping cores, is a different URL. For example, one needs to use http://solrserver:8983/solr, which formerly acted as the admin server AND as the primary core. As of Solr 4.4, one needs to specify the cores separately: http://solrserver:8983/solr/primary and http://solrserver:8983/solr/reindex, and use http://solrserver:8983/solr for swapping cores.
- Parameters:
solrServer-reindexServer-adminServer-primaryCoreName-reindexCoreName-- Throws:
IllegalStateException
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, org.apache.solr.client.solrj.SolrClient adminServer, String primaryCoreName, String reindexCoreName, String namespace) throws IllegalStateException Sets up Solr using multiple clients, one primary, one for reindexing, and one admin to reduce down time during indexing. This constructor should be used when setting up LBHttpSolrClients because primaryCoreName and reindexCoreName need to be provided to SolrConfiguration. Namespace can be specified if managing multiple document sets within the same cores.The adminServer is just a reference to a SolrClient component for connecting to Solr. In newer versions of Solr, 4.4 and beyond, auto discovery of cores is provided. When using a stand-alone server or server cluster, the admin server, for swapping cores, is a different URL. For example, one needs to use http://solrserver:8983/solr, which formerly acted as the admin server AND as the primary core. As of Solr 4.4, one needs to specify the cores separately: http://solrserver:8983/solr/primary and http://solrserver:8983/solr/reindex, and use http://solrserver:8983/solr for swapping cores.
- Parameters:
solrServer-reindexServer-adminServer-primaryCoreName-reindexCoreName-namespace-- Throws:
IllegalStateException
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, String solrCloudConfigName, int solrCloudNumShards) throws IllegalStateException This constructor should be used to set up Solr Cloud using solr cloud config name, number of cloud shards, and multiple clients, one primary, and one for reindexing to reduce down time during indexing. Be sure to set the defaultCollection on the SolrClients correctly before passing them to this constructor.- Parameters:
solrServer-reindexServer-solrCloudConfigName-solrCloudNumShards-- Throws:
IllegalStateException
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.impl.CloudSolrClient solrServer, org.apache.solr.client.solrj.impl.CloudSolrClient reindexServer, String solrCloudConfigName, int solrCloudNumShards, int replicationFactor) throws IllegalStateException - Parameters:
solrServer-reindexServer-solrCloudConfigName-solrCloudNumShards-- Throws:
IllegalStateException
-
SolrConfiguration
public SolrConfiguration(org.apache.solr.client.solrj.SolrClient solrServer, org.apache.solr.client.solrj.SolrClient reindexServer, String solrCloudConfigName, int solrCloudNumShards, String namespace) throws IllegalStateException This constructor should be used to set up Solr Cloud using solr cloud config name, number of cloud shards, and multiple clients, one primary, and one for reindexing to reduce down time during indexing. Be sure to set the defaultCollection on the SolrClients correctly before passing them to this constructor. Namespace can be specified if managing multiple document sets within the same collections.- Parameters:
solrServer-reindexServer-solrCloudConfigName-solrCloudNumShards-namespace-- Throws:
IllegalStateException
-
-
Method Details
-
getPrimaryName
-
setPrimaryName
-
getReindexName
-
setReindexName
-
getSolrCloudConfigName
-
setSolrCloudConfigName
-
getSolrCloudNumShards
-
setSolrCloudNumShards
-
setSolrCloudNumShards
public void setSolrCloudNumShards(int solrCloudNumShards) -
getSolrCloudNumReplicas
-
setSolrCloudNumReplicas
-
getSolrHomePath
-
setSolrHomePath
-
getNamespace
-
setNamespace
-
getAdminServer
public org.apache.solr.client.solrj.SolrClient getAdminServer()The adminServer is just a reference to a SolrClient component for connecting to Solr. In newer versions of Solr, 4.4 and beyond, auto discovery of cores is provided. When using a stand-alone server or server cluster, the admin server, for swapping cores, is a different URL. For example, one needs to use http://solrserver:8983/solr, which formerly acted as the admin server AND as the primary core. As of Solr 4.4, one needs to specify the cores separately: http://solrserver:8983/solr/primary and http://solrserver:8983/solr/reindex, and use http://solrserver:8983/solr for swapping cores.By default, this method attempts to return an admin server if configured. Otherwise, it returns the primary server if the admin server is null, which is backwards compatible with the way that BLC worked prior to this change.
- Returns:
-
setAdminServer
public void setAdminServer(org.apache.solr.client.solrj.SolrClient server) Sets the admin SolrClient instance to communicate with Solr for administrative reasons, like swapping cores. This is typically one of the following:org.apache.solr.client.solrj.embedded.EmbeddedSolrServer,org.apache.solr.client.solrj.impl.HttpSolrServer,org.apache.solr.client.solrj.impl.LBHttpSolrServer, ororg.apache.solr.client.solrj.impl.CloudSolrClientThis should not typically need to be set unless using a stand-alone configuration, where the path to the /admin URI is different than the core URI. This should not typically be set for EmbeddedSolrServer or CloudSolrClient.
- Parameters:
server-
-
getServer
public org.apache.solr.client.solrj.SolrClient getServer()- Returns:
- the primary Solr server
-
setServer
Sets the primary SolrClient instance to communicate with Solr. This is typically one of the following:org.apache.solr.client.solrj.embedded.EmbeddedSolrClient,org.apache.solr.client.solrj.impl.HttpSolrClient,org.apache.solr.client.solrj.impl.LBHttpSolrClient, ororg.apache.solr.client.solrj.impl.CloudSolrClient- Parameters:
server- SolrClient- Throws:
IllegalStateException
-
getReindexServer
public org.apache.solr.client.solrj.SolrClient getReindexServer()- Returns:
- the primary server if
isSingleCoreMode(), else the reindex server
-
setReindexServer
public void setReindexServer(org.apache.solr.client.solrj.SolrClient server) throws IllegalStateException Sets the SolrClient instance that points to the reindex core for the purpose of doing a full reindex, while the primary core is still serving serving requests. This is typically one of the following:org.apache.solr.client.solrj.embedded.EmbeddedSolrServer,org.apache.solr.client.solrj.impl.HttpSolrServer,org.apache.solr.client.solrj.impl.LBHttpSolrServer, ororg.apache.solr.client.solrj.impl.CloudSolrClient- Parameters:
server-- Throws:
IllegalStateException
-
isSingleCoreMode
public boolean isSingleCoreMode()- Returns:
- if this Solr context has a reindex server set not
-
isSolrCloudMode
public boolean isSolrCloudMode() -
afterPropertiesSet
public void afterPropertiesSet() throws org.apache.solr.client.solrj.SolrServerException, IOException, IllegalStateException- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOExceptionIllegalStateException
-
validateCloudSolrClients
protected void validateCloudSolrClients(org.apache.solr.client.solrj.impl.CloudSolrClient primary, org.apache.solr.client.solrj.impl.CloudSolrClient reindex) -
reloadCollectionNames
protected void reloadCollectionNames(org.apache.solr.client.solrj.impl.CloudSolrClient primary, org.apache.solr.client.solrj.impl.CloudSolrClient reindex) throws org.apache.solr.client.solrj.SolrServerException, IOException - Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
aliasCollectionMap
protected Map<String,String> aliasCollectionMap(org.apache.solr.client.solrj.impl.CloudSolrClient client) throws org.apache.solr.client.solrj.SolrServerException, IOException - Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
getSiteServer
public org.apache.solr.client.solrj.SolrClient getSiteServer() -
getSiteReindexServer
public org.apache.solr.client.solrj.SolrClient getSiteReindexServer() -
createCollectionIfNotExist
protected void createCollectionIfNotExist(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName) -
createCollection
protected void createCollection(org.apache.solr.client.solrj.impl.CloudSolrClient client, String collectionName) -
solrCloudConfigName
-
createAliasIfNotExist
-
createAlias
-
getSiteAliasName
- Parameters:
site- the Site- Returns:
- the alias name for the given Site
-
getSiteCollectionName
- Parameters:
site- the Site- Returns:
- the collection name for the given Site
-
getSiteReindexAliasName
- Parameters:
site- the Site- Returns:
- the reindex alias name for the given Site
-
getSiteReindexCollectionName
- Parameters:
site- the Site- Returns:
- the reindex collection name for the given Site
-
getSiteAliasBase
-
setSiteAliasBase
-
getSiteCollectionBase
-
setSiteCollectionBase
-
isSiteCollections
public boolean isSiteCollections()- Returns:
- whether to index a separate collection per site
-
setSiteCollections
public void setSiteCollections(boolean siteCollections) -
getQueryCollectionName
-
getReindexCollectionName
-
determineCoreName
-
destroy
- Throws:
Exception
-