/** * 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( props.getProperty("solr.zookeeper.hosts", DEFAULT_ZOOKEEPER_HOSTS)); } else { client = new HttpSolrClient(props.getProperty("solr.base.url", DEFAULT_SOLR_BASE_URL)); } }
return new HttpSolrClient(solrLocation, httpClient); } else { final String collection = context.getProperty(COLLECTION).evaluateAttributeExpressions().getValue();
@Override public SolrClient create(String spec) { return new HttpSolrClient(spec); } }
String urlString = "http://localhost:8983/solr/gettingstarted"; SolrClient solr = new HttpSolrClient(urlString);
HttpSolrClient server = new HttpSolrClient ( "http://localhost:8983/solr/");
HttpSolrClient server = new HttpSolrClient ( "http://localhost:8983/solr/test");
public synchronized HttpSolrClient getHttpSolrClient(String host) { HttpSolrClient client = null; if (solrClients.containsKey(host)) { client = (HttpSolrClient) solrClients.get(host); } else { client = new HttpSolrClient(host); solrClients.put(host, client); } return client; }
private SolrClient getSolrclient(String core) { SolrClient solrClient; if (isCloud) { solrClient = new CloudSolrClient(zkHosts); } else { solrClient = new HttpSolrClient("http://" + solrHosts + "/solr"); } return solrClient; }
public SolrDocumentSearch(SolrConfiguration config) { this.config = config; this.server = new HttpSolrClient(config.getDocumentUrl()); }
/** * Uses the supplied HttpClient to send documents to the Solr server. */ public ConcurrentUpdateSolrClient(String solrServerUrl, HttpClient client, int queueSize, int threadCount, ExecutorService es, boolean streamDeletes) { this.client = new HttpSolrClient(solrServerUrl, client); this.client.setFollowRedirects(false); queue = new LinkedBlockingQueue<>(queueSize); this.threadCount = threadCount; runners = new LinkedList<>(); scheduler = es; this.streamDeletes = streamDeletes; }
@Override public void initialize() throws InitializationException { String remoteURL = this.configuration.getInstanceConfiguration(TYPE, "url", DEFAULT_REMOTE_URL); // Disabled since this component is initialized when XWiki starts, before any XWikiContext is available, so it // will always fail // try { // this.generateAndAttachConfigurationZipIfNotExist(); // } catch (Exception e) { // // This is not a critical issue, since the remote server may already be configured. // // We still log it as an error though. // this.logger.error("Failed to generate the remote server's configuration.", e); // } // Initialize the remote Solr server. this.server = new HttpSolrClient(remoteURL); }
/** * Create a {@link HttpSolrClient} based on provided configuration. */ public HttpSolrClient build() { if (baseSolrUrl == null) { throw new IllegalArgumentException("Cannot create HttpSolrClient without a valid baseSolrUrl!"); } if (this.invariantParams.get(DelegationTokenHttpSolrClient.DELEGATION_TOKEN_PARAM) == null) { return new HttpSolrClient(this); } else { return new DelegationTokenHttpSolrClient(this); } }
SolrClient client = new HttpSolrClient("http://localhost:8983/solr/jiva/"); String dataDir = System.getProperty("user.dir"); File xmlFile = new File(dataDir + "/Alovera-Juice.xml"); if (xmlFile.exists()) { InputStream is = new FileInputStream(xmlFile); String str = IOUtils.toString(is); DirectXmlRequest dxr = new DirectXmlRequest("/update", str); client.request(dxr); client.commit(); }
private static final Logger LOGGER = Logger.getLogger(SolrCient.class.getName()); private static final String SERVER_URL = "http://localhost:8983/solr/suggest"; public static void main(String[] args) throws IOException, SolrServerException { HttpSolrClient solr = new HttpSolrClient(SERVER_URL); QueryResponse response = solr.query(new SolrQuery("*:*")); System.out.println(response.toString()); }
protected HttpSolrClient makeSolrClient(String server) { HttpSolrClient client = new HttpSolrClient(server, httpClient, parser); if (requestWriter != null) { client.setRequestWriter(requestWriter); } if (queryParams != null) { client.setQueryParams(queryParams); } return client; }
AuthorizedSolrClient<HttpSolrClient> createClient(String shardUrl) { HttpSolrClient solrClient = new HttpSolrClient(shardUrl, createHttpClient()); return new AuthorizedSolrClient<>(solrClient, this); } }
@Bean public HttpSolrClient solrClient(@Value("${solr.url}") String solrUrl, @Value("${solr.pool.maxTotalConnections}") Integer maxTotalConnections) throws MalformedURLException { HttpSolrClient solrClient = new HttpSolrClient(solrUrl); solrClient.setParser(new TextXMLResponseParser()); solrClient.setMaxTotalConnections(maxTotalConnections); solrClient.setDefaultMaxConnectionsPerHost(maxTotalConnections); return solrClient; }
SolrClient server = new HttpSolrClient("http://localhost:8983/solr/my_collection"); ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract"); req.addFile(new File("my-file.pdf")); server.request(req);
private SolrClient initializeWithExistingHttpServer() throws IOException, SolrServerException { // try basic Solr HTTP client HttpSolrClient httpSolrServer = new HttpSolrClient(remoteSolrServerConfiguration.getSolrHttpUrls()[0]); httpSolrServer.setConnectionTimeout(remoteSolrServerConfiguration.getConnectionTimeout()); httpSolrServer.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout()); SolrPingResponse ping = httpSolrServer.ping(); if (ping != null && 0 == ping.getStatus()) { return httpSolrServer; } else { httpSolrServer.close(); throw new IOException("the found HTTP Solr server is not alive"); } }
private SolrClient initializeWithExistingHttpServer() throws IOException, SolrServerException { // try basic Solr HTTP client HttpSolrClient httpSolrServer = new HttpSolrClient(remoteSolrServerConfiguration.getSolrHttpUrls()[0]); httpSolrServer.setConnectionTimeout(remoteSolrServerConfiguration.getConnectionTimeout()); httpSolrServer.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout()); SolrPingResponse ping = httpSolrServer.ping(); if (ping != null && 0 == ping.getStatus()) { return httpSolrServer; } else { httpSolrServer.close(); throw new IOException("the found HTTP Solr server is not alive"); } }