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

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

Introduction

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

Prototype

public void setQueryParams(Set<String> queryParams) 

Source Link

Document

Expert Method

Usage

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  .java  2 s .c  o  m*/

    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;
}