/** * Initialize any state for this DB. Called once per DB instance; there is one DB instance per * client thread. */ @Override public void init() throws DBException { Properties props = getProperties(); commitTime = Integer .parseInt(props.getProperty("solr.commit.within.time", DEFAULT_COMMIT_WITHIN_TIME)); batchMode = Boolean.parseBoolean(props.getProperty("solr.batch.mode", DEFAULT_BATCH_MODE)); String jaasConfPath = props.getProperty("solr.jaas.conf.path"); if(jaasConfPath != null) { System.setProperty("java.security.auth.login.config", jaasConfPath); HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); } // Check if Solr cluster is running in SolrCloud or Stand-alone mode Boolean cloudMode = Boolean.parseBoolean(props.getProperty("solr.cloud", DEFAULT_CLOUD_MODE)); System.err.println("Solr Cloud Mode = " + cloudMode); if (cloudMode) { System.err.println("Solr Zookeeper Remote Hosts = " + props.getProperty("solr.zookeeper.hosts", DEFAULT_ZOOKEEPER_HOSTS)); client = new CloudSolrClient.Builder().withZkHost( Arrays.asList(props.getProperty("solr.zookeeper.hosts", DEFAULT_ZOOKEEPER_HOSTS).split(","))).build(); } else { client = new HttpSolrClient.Builder(props.getProperty("solr.base.url", DEFAULT_SOLR_BASE_URL)).build(); } }
public static List<SolrClient> createHttpSolrClients(Map<String, String> connectionParams, HttpClient httpClient) { List<SolrClient> result = Lists.newArrayList(); for (String shard : SolrConnectionParamUtil.getShards(connectionParams)) { result.add(new HttpSolrClient.Builder(shard).withHttpClient(httpClient).build()); } if (result.size() == 0) { throw new RuntimeException( String.format("You need to specify at least one solr shard connection parameter (%s0={url})", SolrConnectionParams.SOLR_SHARD_PREFIX)); } return result; }
public static List<SolrClient> createHttpSolrClients(Map<String, String> connectionParams, HttpClient httpClient) { List<SolrClient> result = Lists.newArrayList(); for (String shard : SolrConnectionParamUtil.getShards(connectionParams)) { result.add(new HttpSolrClient.Builder(shard).withHttpClient(httpClient).build()); } if (result.size() == 0) { throw new RuntimeException( String.format("You need to specify at least one solr shard connection parameter (%s0={url})", SolrConnectionParams.SOLR_SHARD_PREFIX)); } return result; }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, HttpClient httpClient) { return new Builder(url) .withHttpClient(httpClient) .build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, int connectionTimeoutMillis) { return new Builder(url) .withConnectionTimeout(connectionTimeoutMillis) .build(); }
public SolrIndexIO(Index index) { this._collection = index.getIndexID(); // build client to connect to solr SolrFlintConfig config = SolrFlintConfig.getInstance(); // use cloud? Collection<String> zkhosts = config.getZKHosts(); if (zkhosts != null && !zkhosts.isEmpty()) { this._client = new CloudSolrClient.Builder().withZkHost(zkhosts).build(); } else { this._client = new HttpSolrClient.Builder(config.getServerURL()).allowCompression(true).build(); } }
@PostConstruct public void init() { String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); rootDataverseName = findRootDataverseCached().getName(); }
SolrClient solr = new HttpSolrClient.Builder("<url>").build(); SolrQuery query = new SolrQuery(); query.setQuery("collector:" + input); query.addFilterQuery("(doc_type:" + entity + ")"); query.addSort("lastUpdatedAt", ORDER.desc); query.setFacet(true); query.setStart(pagenumber); query.setRows(pagesize); QueryResponse response = solr.query(query);
public SolrCollectionManager(String url) { this.defaultShards = 1; this.defaultReplicas = 1; this._solr = new HttpSolrClient.Builder(url).allowCompression(true).build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, HttpClient httpClient, ResponseParser responseParser, boolean compression) { return new Builder(url) .withHttpClient(httpClient) .withResponseParser(responseParser) .allowCompression(compression) .build(); }
@Bean @ConditionalOnMissingBean(SolrClient.class) public SolrClient solrClient() { return new HttpSolrClient.Builder(solrProperties().getUrl()).build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, int connectionTimeoutMillis, int socketTimeoutMillis) { return new Builder(url) .withConnectionTimeout(connectionTimeoutMillis) .withSocketTimeout(socketTimeoutMillis) .build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url) { return new Builder(url) .build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, HttpClient httpClient, ResponseParser responseParser) { return new Builder(url) .withHttpClient(httpClient) .withResponseParser(responseParser) .build(); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { getLogger().info("Solr initializing with URL: " + getSolrConfiguration().getSolrServerUrl()); setSolrClient(new HttpSolrClient.Builder(getSolrConfiguration().getSolrServerUrl()).build()); }
@PostConstruct public void init() { String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); }
@PostConstruct public void init() { String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); }
private void createHttpSolrClient() { HttpSolrClient.Builder builder = new HttpSolrClient.Builder().withBaseSolrUrl(this.url); if (timeout != null) { builder = builder.withConnectionTimeout(timeout); } if (maxConnections != null) { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections); builder.withHttpClient(HttpClientUtil.createClient(params)); } this.setSolrClient(builder.build()); }
/** * @deprecated use {@link HttpSolrClient#HttpSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative */ @Deprecated protected HttpSolrClient(String baseURL, HttpClient client, ResponseParser parser, boolean allowCompression) { this(new Builder(baseURL) .withHttpClient(client) .withResponseParser(parser) .allowCompression(allowCompression)); }
private SolrClient getSolrServer () { if (solrServer == null) { } String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); return solrServer; }