Class LBHttp2SolrClient.Builder

    • Field Detail

      • defaultCollection

        protected String defaultCollection
    • Constructor Detail

      • Builder

        @Deprecated
        public Builder​(Http2SolrClient http2Client,
                       String... baseSolrUrls)
        Deprecated.
        Create a Builder object, based on the provided solrClient and Solr URLs.

        Two different paths can be specified as a part of the provided URLs:

        1) A path pointing directly at a particular core

           SolrClient client = new LBHttp2SolrClient.Builder(client, "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 withDefaultCollection(String)

        2) The path of the root Solr path ("/solr")

           SolrClient client = new LBHttp2SolrClient.Builder(client, "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 withDefaultCollection(String).
      • Builder

        public Builder​(Http2SolrClient http2Client,
                       LBSolrClient.Endpoint... endpoints)
        Create a Builder object, based on the provided solrClient and endpoint objects.

        Endpoint instances come in two main flavors:

        1) Endpoints representing a particular core or collection

           SolrClient client = new LBHttp2SolrClient.Builder(
                   client, new LBSolrClient.Endpoint("http://my-solr-server:8983/solr", "core1"))
               .build();
           QueryResponse resp = client.query(new SolrQuery("*:*"));
         
        Note that when a core is provided in the endpoint, 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.

        2) Endpoints representing the root Solr path (i.e. "/solr")

           SolrClient client = new LBHttp2SolrClient.Builder(
                   client, new LBSolrClient.Endpoint("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 withDefaultCollection(String).
    • Method Detail

      • setAliveCheckInterval

        public LBHttp2SolrClient.Builder setAliveCheckInterval​(int aliveCheckInterval,
                                                               TimeUnit unit)
        LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive. Use this to set that interval
        Parameters:
        aliveCheckInterval - how often to ping for aliveness
      • withDefaultCollection

        public LBHttp2SolrClient.Builder withDefaultCollection​(String defaultCoreOrCollection)
        Sets a default for core or collection based requests.

        This method should not be used if the client is provided a Solr URL which already contains a core or collection name.