Example usage for org.apache.solr.client.solrj.impl HttpSolrClient setFollowRedirects

List of usage examples for org.apache.solr.client.solrj.impl HttpSolrClient setFollowRedirects

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.impl HttpSolrClient setFollowRedirects.

Prototype

public void setFollowRedirects(boolean followRedirects) 

Source Link

Document

Configure whether the client should follow redirects or not.

Usage

From source file:org.dbflute.solr.bhv.AbstractSolrBehavior.java

License:Apache License

/**
 * Create HttpSolrClient associated with the assigned URL.
 * @param url URL (NotNull)//from w  w w  .  j ava2  s.c  o m
 * @return HttpSolrClient (NotNull)
 */
protected HttpSolrClient createHttpSolrClient(String url) {
    HttpSolrClient client = new HttpSolrClient(url);
    client.setConnectionTimeout(getConnectionTimeout());
    client.setSoTimeout(getSocketTimeout());
    client.setDefaultMaxConnectionsPerHost(getDefaultMaxConnectionsPerHost());
    client.setMaxTotalConnections(getMaxTotalConnections());
    client.setFollowRedirects(false);
    return client;
}

From source file:org.seedstack.solr.internal.SolrPlugin.java

License:Mozilla Public License

private SolrClient buildHttpSolrClient(Configuration solrClientConfiguration, String url) {
    HttpSolrClient httpSolrClient = new HttpSolrClient(url);

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.CONNECTION_TIMEOUT)) {
        httpSolrClient.setConnectionTimeout(
                solrClientConfiguration.getInt(SolrConfigurationConstants.CONNECTION_TIMEOUT));
    }//w  w  w. j a v a2  s. com

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.QUERY_PARAMS)) {
        httpSolrClient.setQueryParams(Sets
                .newHashSet(solrClientConfiguration.getStringArray(SolrConfigurationConstants.QUERY_PARAMS)));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.SO_TIMEOUT)) {
        httpSolrClient.setSoTimeout(solrClientConfiguration.getInt(SolrConfigurationConstants.SO_TIMEOUT));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.ALLOW_COMPRESSION)) {
        httpSolrClient.setAllowCompression(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.ALLOW_COMPRESSION));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.MAX_CONNECTIONS_PER_HOST)) {
        httpSolrClient.setDefaultMaxConnectionsPerHost(
                solrClientConfiguration.getInt(SolrConfigurationConstants.MAX_CONNECTIONS_PER_HOST));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.FOLLOW_REDIRECTS)) {
        httpSolrClient.setFollowRedirects(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.FOLLOW_REDIRECTS));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.MAX_TOTAL_CONNECTIONS)) {
        httpSolrClient.setMaxTotalConnections(
                solrClientConfiguration.getInt(SolrConfigurationConstants.MAX_TOTAL_CONNECTIONS));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.USE_MULTI_PART_HOST)) {
        httpSolrClient.setUseMultiPartPost(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.USE_MULTI_PART_HOST));
    }

    return httpSolrClient;
}

From source file:org.springframework.data.solr.server.support.SolrClientUtilTests.java

License:Apache License

@Test
public void testClonesHttpSolrClientCorrectly() {
    HttpSolrClient httpSolrClient = new HttpSolrClient(BASE_URL);
    httpSolrClient.setDefaultMaxConnectionsPerHost(10);
    httpSolrClient.setFollowRedirects(true);
    httpSolrClient.setUseMultiPartPost(true);

    HttpSolrClient clone = SolrClientUtils.clone(httpSolrClient);
    Assert.assertEquals(httpSolrClient.getBaseURL(), clone.getBaseURL());
    assertHttpSolrClientProperties(httpSolrClient, clone);
}

From source file:org.springframework.data.solr.server.support.SolrClientUtilTests.java

License:Apache License

@Test
public void testClonesHttpSolrClientForCoreCorrectly() {
    HttpSolrClient httpSolrClient = new HttpSolrClient(BASE_URL);
    httpSolrClient.setDefaultMaxConnectionsPerHost(10);
    httpSolrClient.setFollowRedirects(true);
    httpSolrClient.setUseMultiPartPost(true);

    HttpSolrClient clone = SolrClientUtils.clone(httpSolrClient, CORE_NAME);

    Assert.assertEquals(CORE_URL, clone.getBaseURL());

    assertHttpSolrClientProperties(httpSolrClient, clone);
}