@Override protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException { if (r.nextBoolean()) params.set("collection", DEFAULT_COLLECTION); return cloudClient.query(params); }
@Override public void run() { Random random = LuceneTestCase.random(); int numSearches = 0; while (!stop) { numSearches++; try { //to come to the aid of their country. cloudClient.query(new SolrQuery(QUERIES[random.nextInt(QUERIES.length)])); } catch (Exception e) { System.err.println("QUERY REQUEST FAILED:"); e.printStackTrace(); if (e instanceof SolrServerException) { System.err.println("ROOT CAUSE:"); ((SolrServerException) e).getRootCause().printStackTrace(); } queryFails.incrementAndGet(); } try { Thread.sleep(random.nextInt(4000) + 300); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } log.info("num searches done:" + numSearches + " with " + queryFails + " fails"); }
void doQuery(String expectedDocs, String... queryParams) throws Exception { Set<String> expectedIds = new HashSet<>( StrUtils.splitSmart(expectedDocs, ",", true) ); QueryResponse rsp = cloudClient.query(params(queryParams)); Set<String> obtainedIds = new HashSet<>(); for (SolrDocument doc : rsp.getResults()) { obtainedIds.add((String) doc.get("id")); } assertEquals(expectedIds, obtainedIds); }
@Override public Iterator<Node> listGraphNodes() { try { final QueryResponse response = cloud.query(LIST_GRAPHS_QUERY); final FacetField graphFacetField = response.getFacetField(Field.C); if (graphFacetField != null && graphFacetField.getValueCount() > 0) { final List<Node> graphs = new ArrayList<Node>(); for (final FacetField.Count graphName : graphFacetField.getValues()) { graphs.add(NTriples.asURI(graphName.getName())); } return graphs.iterator(); } return EMPTY_GRAPHS_ITERATOR; } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } }
SolrQuery query = new SolrQuery("*:*"); assertEquals("Doc Counts do not add up", controlCount, cloudClient.query(query).getResults().getNumFound());
long controlDocs = controlDocList.getNumFound(); SolrDocumentList cloudDocList = cloudClient.query(q).getResults(); long cloudClientDocs = cloudDocList.getNumFound();
@Override protected boolean _containsGraph(final Node graphNode) { final SolrQuery query = new SolrQuery("*:*") .addFilterQuery(fq(Field.C, asNtURI(graphNode))) .setRows(0); try { return cloud.query(query).getResults().getNumFound() > 0; } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } } }
.query(COLLECTION, new SolrQuery("*:*").setRows(100000).addSort("id", SolrQuery.ORDER.asc)); assertEquals(2104, collector.getRecords().size()); assertEquals(collector.getRecords().size(), rsp.getResults().size());
.query(COLLECTION, new SolrQuery("*:*").setRows(100000).addSort(Fields.ID, SolrQuery.ORDER.asc));
.query(COLLECTION, new SolrQuery("*:*").setRows(100000).addSort(Fields.ID, SolrQuery.ORDER.asc));