QueryResponse response = solrClient.query(collection, solrQuery); if (logger.isDebugEnabled()) logger.debug("Executed query [{}] in {} ms", query.getQuery(), response.getElapsedTime());
final QueryResponse response = client.query(table, query); SolrDocumentList results = response.getResults();
final QueryResponse response = client.query(table, query); SolrDocumentList results = response.getResults();
query.setFields(fieldList); final QueryResponse response = client.query(table, query); SolrDocumentList results = response.getResults(); if ((results != null) && (results.getNumFound() > 0)) {
query.setFields(fieldList); final QueryResponse response = client.query(table, query); SolrDocumentList results = response.getResults(); if ((results != null) && (results.getNumFound() > 0)) {
QueryResponse response = solrClient.query(collection, solrQuery);
int numResults = 0; try { response = solrConfiguration.getServer().query(solrQuery, getSolrQueryMethod()); responseDocuments = getResponseDocuments(response); numResults = (int) response.getResults().getNumFound();
@Override public GroupResponse group(GroupRequest groupRequest) throws InvalidSearchException { try { String groupNames = groupRequest.getGroups().stream().map(Group::getField).collect( Collectors.joining(",")); SolrQuery query = new SolrQuery() .setStart(0) .setRows(0) .setQuery(groupRequest.getQuery()); query.set("collection", getCollections(groupRequest.getIndices())); Optional<String> scoreField = groupRequest.getScoreField(); if (scoreField.isPresent()) { query.set("stats", true); query.set("stats.field", String.format("{!tag=piv1 sum=true}%s", scoreField.get())); } query.set("facet", true); query.set("facet.pivot", String.format("{!stats=piv1}%s", groupNames)); QueryResponse response = client.query(query); return buildGroupResponse(groupRequest, response); } catch (IOException | SolrServerException e) { String msg = e.getMessage(); LOG.error(msg, e); throw new InvalidSearchException(msg, e); } }
public SearchResponse search(SearchRequest searchRequest, String fieldList) throws InvalidSearchException { if (searchRequest.getQuery() == null) { throw new InvalidSearchException("Search query is invalid: null"); } if (client == null) { throw new InvalidSearchException("Uninitialized Dao! You must call init() prior to use."); } if (searchRequest.getSize() > accessConfig.getMaxSearchResults()) { throw new InvalidSearchException( "Search result size must be less than " + accessConfig.getMaxSearchResults()); } try { SolrQuery query = buildSearchRequest(searchRequest, fieldList); QueryResponse response = client.query(query); return buildSearchResponse(searchRequest, response); } catch (SolrException | IOException | SolrServerException e) { String msg = e.getMessage(); LOG.error(msg, e); throw new InvalidSearchException(msg, e); } }
while (!done) { solrQuery.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark); QueryResponse rsp = solrClient.query(METAALERTS_COLLECTION, solrQuery); String nextCursorMark = rsp.getNextCursorMark(); rsp.getResults().stream()
@Override public Document getLatest(String guid, String sensorType) throws IOException { if (MetaAlertConstants.METAALERT_TYPE.equals(sensorType)) { // Unfortunately, we can't just defer to the indexDao for this. Child alerts in Solr end up // having to be dug out. String guidClause = Constants.GUID + ":" + guid; SolrQuery query = new SolrQuery(); query.setQuery(guidClause) .setFields("*", "[child parentFilter=" + guidClause + " limit=999]"); try { QueryResponse response = solrDao.getSolrClient(solrDao.getZkHosts()) .query(METAALERTS_COLLECTION, query); // GUID is unique, so it's definitely the first result if (response.getResults().size() == 1) { SolrDocument result = response.getResults().get(0); return SolrUtilities.toDocument(result); } else { return null; } } catch (SolrServerException e) { throw new IOException("Unable to retrieve metaalert", e); } } else { return solrDao.getLatest(guid, sensorType); } }
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException { // query a random server int which = r.nextInt(clients.size()); SolrClient client = clients.get(which); QueryResponse rsp = client.query(params); return rsp; }
public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrClient> clients) throws SolrServerException, IOException { QueryResponse first = null; for (SolrClient client : clients) { QueryResponse rsp = client.query(new ModifiableSolrParams(params)); if (first == null) { first = rsp; } else { compareResponses(first, rsp); } } return first; }
public boolean existsInIndex(String username) { SolrQuery solrQuery = new SolrQuery().setQuery("name:" + username); try { return 1 == solrClient.query(solrQuery).getResults().getNumFound(); } catch (SolrServerException | IOException e) { throw new RuntimeException(e); } }
public static void doQuery(SolrClient ss, String id) throws SolrServerException, IOException { SolrParams p = new SolrQuery("id:\"" + id + "\""); QueryResponse r = ss.query(p); System.out.println("GOT collection " + r.getResults().get(0).getFieldValue("collection")); System.out.println("GOT collections " + r.getResults().get(0).getFieldValue("collections")); System.out.println("STILL GOT crawl_date " + r.getResults().get(0).getFieldValue("crawl_date")); }
@Override protected int graphBaseSize() { try { return (int)cloud.query(graphSizeQuery()).getResults().getNumFound(); } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } }
@Override public long countCollection(String name) throws DatastoreClientServiceException { try { SolrQuery q = new SolrQuery("*:*"); q.setRows(0); // don't actually request any data return getClient().query(name, q).getResults().getNumFound(); } catch (Exception e) { throw new DatastoreClientServiceException(e); } }
protected QueryResponse query(String query) { try { testServer.commitTransaction(); solrClient.commit(false, true, true); QueryResponse rsp = solrClient.query( new SolrQuery(query).setRows(Integer.MAX_VALUE).setSort(Fields.ID, SolrQuery.ORDER.asc)); return rsp; } catch (Exception e) { throw new RuntimeException(e); } }
@Test public void testGetNotFromSearch() throws Exception { Query query = new Query(ANNOT_PROTEIN_SUBSTITUTION.key(), "sift>0.1"); VariantQueryResult<Variant> result = variantStorageEngine.get(query, new QueryOptions()); verify(solrClient, never()).query(anyString(), any()); assertThat(result, everyResult(allVariants, hasAnnotation(hasSift(hasItem(gt(0.1)))))); }
private void testGoodRequestNeedsNoRetries(MetricsFacade metricsFacade) throws Exception { CountingSolrServer countingSolrServer = new CountingSolrServer(solrServer); SolrClient solr = new RetryingSolrServer(countingSolrServer, getNoRetryPolicyFactory(), metricsFacade); SolrQuery query = getDefaultQuery(); solr.query(query); Assert.assertEquals(1, countingSolrServer.getNumRequests()); }