public QueryResponse basicQuery(ModifiableSolrParams params) { try { QueryResponse response = server.query(params); return response; } catch(SolrServerException e) { return null; } }
public QueryResponse basicQuery(ModifiableSolrParams params) { try { QueryResponse response = server.query(params); return response; } catch(SolrServerException e) { return null; } }
/** * Takes up one dead server and check for aliveness. The check is done in a roundrobin. Each server is checked for * aliveness once in 'x' millis where x is decided by the setAliveCheckinterval() or it is defaulted to 1 minute * * @param zombieServer a server in the dead pool */ private void checkAZombieServer(ServerWrapper zombieServer) { long currTime = System.currentTimeMillis(); checkLock.lock(); try { zombieServer.lastChecked = currTime; QueryResponse resp = zombieServer.solrServer.query(solrQuery); if (resp.getStatus() == 0) { //server has come back up zombieServer.lastUsed = currTime; zombieServers.remove(zombieServer); aliveServers.add(zombieServer); zombieServer.failedPings = 0; } } catch (Exception e) { zombieServer.failedPings++; //Expected . The server is still down } finally { checkLock.unlock(); } }
public void execute(String query) throws SolrServerException, IOException { Map<String, String> params = new HashMap<String, String>(); params.put("q", query); params.put("rows", "10"); MapSolrParams solrParams = new MapSolrParams(params); QueryResponse response = solr.query(solrParams); long numbFound = response.getResults().getNumFound(); // process the first batch process(response.getResults()); // Run over the rest for (int i = 10; i < numbFound; i += 10) { params.put("start", String.valueOf(i)); solrParams = new MapSolrParams(params); response = solr.query(solrParams); process(response.getResults()); } }
public QueryResponse query(ModifiableSolrParams params) throws SolrServerException { try { QueryResponse response = server.query(params); if(response.getStatus() != 0) { solrTracker.setSolrActive(false); } return response; } catch(SolrServerException e) { solrTracker.setSolrActive(false); throw e; } }
public QueryResponse query(ModifiableSolrParams params) throws SolrServerException { try { QueryResponse response = server.query(params); if(response.getStatus() != 0) { solrTracker.setSolrActive(false); } return response; } catch(SolrServerException e) { solrTracker.setSolrActive(false); throw e; } }
params.put("rows", "1"); MapSolrParams solrParams = new MapSolrParams(params); QueryResponse response = solr.query(solrParams);
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);
solrQuery.addFilterQuery(filterquery); QueryResponse rsp = getSolr().query(solrQuery); SolrDocumentList docs = rsp.getResults();
.setQuery("search.resourcetype:2 AND search.resourceid:1"); solr.query(solrQuery);
response = solr.query(solrQuery);
rsp = getSolr().query(query); } catch (SolrServerException e) { throw new SearchServiceException(e.getMessage(),e);
long totalRecords = solr.query(query).getResults().getNumFound();
SolrQuery query = new SolrQuery(); query.setQuery("*:*"); QueryResponse rsp = getSolr().query(query); SolrDocumentList docs = rsp.getResults();
QueryResponse queryResponse = getSolr().query(solrQuery); return retrieveResult(context, discoveryQuery, queryResponse);
@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")); } }