Class LBHttpSolrClient.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • withBaseSolrUrl

        @Deprecated
        public LBHttpSolrClient.Builder withBaseSolrUrl​(String baseSolrUrl)
        Deprecated.
        use withBaseEndpoint(String) or withCollectionEndpoint(String, String) instead, based on the type of URL string currently being supplied
        Provide a Solr endpoint to be used when configuring LBHttpSolrClient instances.

        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 configuring LBHttpSolrClient instances.

        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 configuring LBHttpSolrClient instances.

        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 configuring LBHttpSolrClient instances.

        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 configuring LBHttpSolrClient instances.

        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 either withBaseEndpoints(String...) or withCollectionEndpoints(Endpoint...), based on the type of URL strings currently used.
        Provide Solr endpoints to be used when configuring LBHttpSolrClient instances.

        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 of SolrClientBuilder.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