CommonsHttpSolrServer solrj = new CommonsHttpSolrServer("http://" + addr.getHostAddress() + ":" + CassandraUtils.port + "/solandra/" + subIndex, new HttpClient(httpConnections));
public SolrConsumer(String url) throws MalformedURLException { this.solr = new CommonsHttpSolrServer(url); }
public WikipediaIndexer() throws MalformedURLException { server = new CommonsHttpSolrServer(DEFAULT_SOLR_URL); }
public WikipediaWexIndexer() throws MalformedURLException { this.server = new CommonsHttpSolrServer(DEFAULT_SOLR_URL); }
public IntactSolrIndexer(String solrServerUrl) throws MalformedURLException { this(new CommonsHttpSolrServer(solrServerUrl)); }
SolrServer solr = new CommonsHttpSolrServer("http://localhost:8983/solr");
public LBHttpSolrServer(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) throws MalformedURLException { this.httpClient = httpClient; for (String s : solrServerUrl) { aliveServers.add(new ServerWrapper(new CommonsHttpSolrServer(s, httpClient, parser))); } }
public SolrServer getSolrServer(String coreName) { try { solrServer = new CommonsHttpSolrServer(getSolrUrl(coreName)); } catch (MalformedURLException e) { throw new IllegalStateException("URL should be well formed", e); } return solrServer; }
public void addSolrServer(String server) throws MalformedURLException { CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(server, httpClient); checkLock.lock(); try { aliveServers.add(new ServerWrapper(solrServer)); } finally { checkLock.unlock(); } }
public IntactSolrIndexer(String solrServerUrl, String ontologySolrServerUrl) throws MalformedURLException { this(new CommonsHttpSolrServer(solrServerUrl), new StreamingUpdateSolrServer(ontologySolrServerUrl.toString(), 2, 2)); }
public MovieMatcher() throws MalformedURLException { solr = new CommonsHttpSolrServer(new URL("http://localhost:8983/solr")); query = new SolrQuery(); query.setRows(10); }
public SpellCorrector(StringDistance sd, float threshold) throws MalformedURLException { solr = new CommonsHttpSolrServer( new URL("http://localhost:8983/solr")); query = new SolrQuery(); query.setFields("word"); query.setRows(50); //<co id="co.dym.num"/> this.sd = sd; this.threshold = threshold; }
SolrServer server = new CommonsHttpSolrServer("http://localhost:8983/solr"); ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract"); req.addFile(new File("myxml.xml")); req.setParam(ExtractingParams.EXTRACT_ONLY, "true"); NamedList<Object> result = server.request(req); System.out.println("Result: " + result);
public BasicAuthSolrServer(String username, String password, String url) throws MalformedURLException { HttpClient httpClient = new HttpClient( new MultiThreadedHttpConnectionManager()); if (username != null && password != null) { HttpState httpState = httpClient.getState(); httpState.setCredentials( AuthScope.ANY, new UsernamePasswordCredentials(username, password)); HttpClientParams httpClientParams = httpClient.getParams(); httpClientParams.setAuthenticationPreemptive(true); } solrServer = new CommonsHttpSolrServer(url, httpClient); }
SolrServer solr = new CommonsHttpSolrServer("http://localhost:8983/solr"); ModifiableSolrParams params = new ModifiableSolrParams(); params.set("qt", "/dataimport"); params.set("command", "full-import"); QueryResponse response = solr.query(params);
String qry="*:*"; SolrQuery query = new SolrQuery(); query.setQuery("*:*"); query.setRows(Integer.MAX_VALUE); //Add me to avoid IndexOutOfBoundExc CommonsHttpSolrServer server = new CommonsHttpSolrServer("http://localhost:8983/solr"); QueryResponse rsp=server.query(query); SolrDocumentList docs=rsp.getResults(); for(int i=0;i<docs.getNumFound();i++){ System.out.println(docs.get(i)); }
CommonsHttpSolrServer commonsHttpSolrServer = new CommonsHttpSolrServer("solr_path_url"); commonsHttpSolrServer.setParser(new XMLResponseParser()); ModifiableSolrParams params = new ModifiableSolrParams(); // Specify the Request handler params.add("qt", "dismax_request_handler"); params.add("q", "query_string"); QueryResponse response = commonsHttpSolrServer.query(params);
SolrServer solr = new CommonsHttpSolrServer("http://localhost:8080/solr"); ModifiableSolrParams params = new ModifiableSolrParams(); params.set("qt", "/spell"); params.set("q", "whatever"); params.set("spellcheck", "on"); //params.set("spellcheck.build", "true"); QueryResponse response = solr.query(params); SpellCheckResponse spellCheckResponse = response.getSpellCheckResponse(); if (!spellCheckResponse.isCorrectlySpelled()) { for (Suggestion suggestion : response.getSpellCheckResponse().getSuggestions()) { logger.debug("original token: " + suggestion.getToken() + " - alternatives: " + suggestion.getAlternatives()); } }
public class SolrReader implements ItemReader<SolrDocumentList> { @Override public SolrDocumentList read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { SolrServer solr = new CommonsHttpSolrServer("http://localhost:8983/solr"); ModifiableSolrParams params = new ModifiableSolrParams(); params.set("qt", "/select"); params.set("q", "*:*"); params.set("spellcheck", "on"); params.set("spellcheck.build", "true"); QueryResponse response = solr.query(params); SolrDocumentList results = response.getResults(); return results; } }
@Test public void testSolr() throws IOException, SolrServerException { Set<Cluster.Instance> instances = cluster.getInstancesMatching(role(SOLR_ROLE)); for (Cluster.Instance instance : instances) { String publicIp = instance.getPublicIp(); LOG.info("Adding a document to instance " + instance.getId() + " @ " + publicIp); CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(String.format("http://%s:%s/solr/core0", instance.getPublicHostName(), SOLR_PORT)); SolrInputDocument doc = new SolrInputDocument(); doc.addField("name", "Apache Whirr"); doc.addField("inceptionYear", "2010"); solrServer.add(doc); solrServer.commit(); LOG.info("Committed document to instance " + instance.getId() + " @ " + publicIp); LOG.info("Performing a search on instance " + instance.getId() + " @ " + publicIp); SolrQuery query = new SolrQuery("name:whirr"); QueryResponse response = solrServer.query(query); SolrDocumentList results = response.getResults(); assertEquals("Search on instance " + instance.getId() + " did NOT return a document!" , 1, results.size()); SolrDocument resultDoc = results.get(0); assertEquals("name field on document of instance " + instance.getId() + " is incorrect", "Apache Whirr", resultDoc.get("name")); } }