Class LBHttpSolrClient.Builder
- java.lang.Object
-
- org.apache.solr.client.solrj.impl.SolrClientBuilder<LBHttpSolrClient.Builder>
-
- org.apache.solr.client.solrj.impl.LBHttpSolrClient.Builder
-
- Enclosing class:
- LBHttpSolrClient
public static class LBHttpSolrClient.Builder extends SolrClientBuilder<LBHttpSolrClient.Builder>
ConstructsLBHttpSolrClientinstances from provided configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>baseSolrUrlsstatic intCHECK_INTERVALprotected HttpSolrClient.BuilderhttpSolrClientBuilder-
Fields inherited from class org.apache.solr.client.solrj.impl.SolrClientBuilder
connectionTimeoutMillis, defaultCollection, followRedirects, httpClient, requestWriter, responseParser, socketTimeoutMillis, timeToLiveSeconds, urlParamNames, useMultiPartPost
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LBHttpSolrClientbuild()Create aHttpSolrClientbased on provided configuration.HttpSolrClient.BuildergetHttpSolrClientBuilder()LBHttpSolrClient.BuildergetThis()The solution for the unchecked cast warning.LBHttpSolrClient.BuildersetAliveCheckInterval(int aliveCheckInterval)LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive.LBHttpSolrClient.BuilderwithBaseEndpoint(String rootUrl)Provide a "base" Solr URL to be used when configuringLBHttpSolrClientinstances.LBHttpSolrClient.BuilderwithBaseEndpoints(String... baseSolrUrls)Provide multiple "base" Solr URLs to be used when configuringLBHttpSolrClientinstances.LBHttpSolrClient.BuilderwithBaseSolrUrl(String baseSolrUrl)Deprecated.usewithBaseEndpoint(String)orwithCollectionEndpoint(String, String)instead, based on the type of URL string currently being suppliedLBHttpSolrClient.BuilderwithBaseSolrUrls(String... solrUrls)Deprecated.use eitherwithBaseEndpoints(String...)orwithCollectionEndpoints(Endpoint...), based on the type of URL strings currently used.LBHttpSolrClient.BuilderwithCollectionEndpoint(String rootUrl, String collection)Provide a core/collection Solr endpoint to be used when configuringLBHttpSolrClientinstances.LBHttpSolrClient.BuilderwithCollectionEndpoints(LBSolrClient.Endpoint... endpoints)Provide multiple core/collection endpoints to be used when configuringLBHttpSolrClientinstances.LBHttpSolrClient.BuilderwithHttpSolrClientBuilder(HttpSolrClient.Builder builder)Provides aHttpSolrClient.Builderto be used for building the internally used clients.-
Methods inherited from class org.apache.solr.client.solrj.impl.SolrClientBuilder
allowMultiPartPost, getConnectionTimeoutMillis, getSocketTimeoutMillis, withConnectionTimeout, withConnectionTimeout, withDefaultCollection, withFollowRedirects, withHttpClient, withRequestWriter, withResponseParser, withSocketTimeout, withSocketTimeout, withTheseParamNamesInTheUrl
-
-
-
-
Field Detail
-
CHECK_INTERVAL
public static final int CHECK_INTERVAL
- See Also:
- Constant Field Values
-
httpSolrClientBuilder
protected HttpSolrClient.Builder httpSolrClientBuilder
-
-
Method Detail
-
getHttpSolrClientBuilder
public HttpSolrClient.Builder getHttpSolrClientBuilder()
-
withBaseSolrUrl
@Deprecated public LBHttpSolrClient.Builder withBaseSolrUrl(String baseSolrUrl)
Deprecated.usewithBaseEndpoint(String)orwithCollectionEndpoint(String, String)instead, based on the type of URL string currently being suppliedProvide a Solr endpoint to be used when configuringLBHttpSolrClientinstances.Method may be called multiple times. All provided values will be used.
Two different paths can be specified as a part of the URL:
1) A path pointing directly at a particular core
SolrClient client = builder.withBaseSolrUrl("http://my-solr-server:8983/solr/core1").build(); QueryResponse resp = client.query(new SolrQuery("*:*"));Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the core explicitly. However, the client can only send requests to that core. Attempts to make core-agnostic requests, or requests for other cores will fail.Use of these core-based URLs is deprecated and will not be supported in Solr 10.0 Users should instead provide base URLs as described below, and provide a "default collection" as desired using
SolrClientBuilder.withDefaultCollection(String)2) The path of the root Solr path ("/solr")
SolrClient client = builder.withBaseSolrUrl("http://my-solr-server:8983/solr").build(); QueryResponse resp = client.query("core1", new SolrQuery("*:*"));In this case the client is more flexible and can be used to send requests to any cores. This flexibility though requires that the core is specified on all requests.
-
withBaseEndpoint
public LBHttpSolrClient.Builder withBaseEndpoint(String rootUrl)
Provide a "base" Solr URL to be used when configuringLBHttpSolrClientinstances.Method may be called multiple times. All provided values will be used. However, all endpoints must be of the same type: providing a mix of "base" endpoints via this method and core/collection endpoints via
withCollectionEndpoint(String, String)is prohibited.Users who use this method to provide base Solr URLs may specify a "default collection" for their requests using
SolrClientBuilder.withDefaultCollection(String)if they wish to avoid needing to specify a collection or core on relevant requests.- Parameters:
rootUrl- the base URL for a Solr node, in the form "http[s]://hostname:port/solr"
-
withBaseEndpoints
public LBHttpSolrClient.Builder withBaseEndpoints(String... baseSolrUrls)
Provide multiple "base" Solr URLs to be used when configuringLBHttpSolrClientinstances.Method may be called multiple times. All provided values will be used. However, all endpoints must be of the same type: providing a mix of"base" endpoints via this method and core/collection endpoints via
withCollectionEndpoint(String, String)is prohibited.Users who use this method to provide base Solr URLs may specify a "default collection" for their requests using
SolrClientBuilder.withDefaultCollection(String)if they wish to avoid needing to specify a collection or core on relevant requests.- Parameters:
baseSolrUrls- Solr base URLs, in the form "http[s]://hostname:port/solr"
-
withCollectionEndpoint
public LBHttpSolrClient.Builder withCollectionEndpoint(String rootUrl, String collection)
Provide a core/collection Solr endpoint to be used when configuringLBHttpSolrClientinstances.Method may be called multiple times. All provided values will be used. However, all endpoints must be of the same type: providing a mix of "core" endpoints via this method and base endpoints via
withBaseEndpoint(String)is prohibited.- Parameters:
rootUrl- the base URL for a Solr node, in the form "http[s]://hostname:port/solr"collection- the Solr core or collection to target
-
withCollectionEndpoints
public LBHttpSolrClient.Builder withCollectionEndpoints(LBSolrClient.Endpoint... endpoints)
Provide multiple core/collection endpoints to be used when configuringLBHttpSolrClientinstances.Method may be called multiple times. All provided values will be used. However, all endpoints must be of the same type: providing a mix of "core" endpoints via this method and base endpoints via
withBaseEndpoint(String)is prohibited.- Parameters:
endpoints- endpoint instances pointing to distinct cores/collections
-
withBaseSolrUrls
@Deprecated public LBHttpSolrClient.Builder withBaseSolrUrls(String... solrUrls)
Deprecated.use eitherwithBaseEndpoints(String...)orwithCollectionEndpoints(Endpoint...), based on the type of URL strings currently used.Provide Solr endpoints to be used when configuringLBHttpSolrClientinstances.Method may be called multiple times. All provided values will be used.
Two different paths can be specified as a part of each URL:
1) A path pointing directly at a particular core
SolrClient client = builder.withBaseSolrUrls("http://my-solr-server:8983/solr/core1").build(); QueryResponse resp = client.query(new SolrQuery("*:*"));Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the core explicitly. However, the client can only send requests to that core. Attempts to make core-agnostic requests, or requests for other cores will fail.Use of these core-based URLs is deprecated and will not be supported in Solr 10.0 Users should instead provide base URLs as described below, and provide a "default collection" as desired using
SolrClientBuilder.withDefaultCollection(String)2) The path of the root Solr path ("/solr")
SolrClient client = builder.withBaseSolrUrls("http://my-solr-server:8983/solr").build(); QueryResponse resp = client.query("core1", new SolrQuery("*:*"));In this case the client is more flexible and can be used to send requests to any cores. Users can still provide a "default" collection if desired through use ofSolrClientBuilder.withDefaultCollection(String).
-
setAliveCheckInterval
public LBHttpSolrClient.Builder setAliveCheckInterval(int aliveCheckInterval)
LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive. Use this to set that interval- Parameters:
aliveCheckInterval- time in milliseconds
-
withHttpSolrClientBuilder
public LBHttpSolrClient.Builder withHttpSolrClientBuilder(HttpSolrClient.Builder builder)
Provides aHttpSolrClient.Builderto be used for building the internally used clients.
-
build
public LBHttpSolrClient build()
Create aHttpSolrClientbased on provided configuration.
-
getThis
public LBHttpSolrClient.Builder getThis()
Description copied from class:SolrClientBuilderThe solution for the unchecked cast warning.- Specified by:
getThisin classSolrClientBuilder<LBHttpSolrClient.Builder>
-
-