entry = new HashMap<>((int) results.getNumFound()); for (String field : hit.getFieldNames()) { entry.put(field, new StringByteIterator(String.valueOf(hit.getFirstValue(field))));
entry = new HashMap<String, ByteIterator>((int) results.getNumFound()); for (String field : hit.getFieldNames()) { entry.put(field, new StringByteIterator(String.valueOf(hit.getFirstValue(field))));
if ((results != null) && (results.getNumFound() > 0)) { for (String field : results.get(0).getFieldNames()) { result.put(field,
if ((results != null) && (results.getNumFound() > 0)) { for (String field : results.get(0).getFieldNames()) { result.put(field,
timer.stop(); final Long totalNumberOfResults = response.getResults().getNumFound();
response = solrConfiguration.getServer().query(solrQuery, getSolrQueryMethod()); responseDocuments = getResponseDocuments(response); numResults = (int) response.getResults().getNumFound();
protected SearchResponse buildSearchResponse( SearchRequest searchRequest, QueryResponse solrResponse) { SearchResponse searchResponse = new SearchResponse(); SolrDocumentList solrDocumentList = solrResponse.getResults(); searchResponse.setTotal(solrDocumentList.getNumFound()); // search hits --> search results List<SearchResult> results = solrDocumentList.stream() .map(solrDocument -> SolrUtilities.getSearchResult(solrDocument, searchRequest.getFields(), accessConfig.getIndexSupplier())) .collect(Collectors.toList()); searchResponse.setResults(results); // handle facet fields List<String> facetFields = searchRequest.getFacetFields(); if (facetFields != null) { searchResponse.setFacetCounts(getFacetCounts(facetFields, solrResponse)); } if (LOG.isDebugEnabled()) { String response; try { response = JSONUtils.INSTANCE.toJSON(searchResponse, false); } catch (JsonProcessingException e) { response = e.getMessage(); } LOG.debug("Built search response; response={}", response); } return searchResponse; }
/** * Returns the count of docs that have been found.<p> * * @return the count of docs that have been found */ public long getNumFound() { return m_resultDocuments.getNumFound(); }
@Override public long size() { return getResults() instanceof SolrDocumentList ? ((SolrDocumentList) results).getNumFound() : results.size(); }
public void writeSolrDocumentList(SolrDocumentList docs) throws IOException { writeTag(SOLRDOCLST); List<Number> l = new ArrayList<>(3); l.add(docs.getNumFound()); l.add(docs.getStart()); l.add(docs.getMaxScore()); writeArray(l); writeArray(docs); }
public void writeSolrDocumentList(SolrDocumentList docs) throws IOException { writeTag(SOLRDOCLST); List l = new ArrayList(3); l.add(docs.getNumFound()); l.add(docs.getStart()); l.add(docs.getMaxScore()); writeArray(l); writeArray(docs); }
public void writeSolrDocumentList(SolrDocumentList docs) throws IOException { writeTag(SOLRDOCLST); List<Number> l = new ArrayList<>(3); l.add(docs.getNumFound()); l.add(docs.getStart()); l.add(docs.getMaxScore()); writeArray(l); writeArray(docs); }
private QueryResult retrieveItems(List<ScopedFilter> filters, int offset, int length) throws DSpaceSolrException { List<Item> list = new ArrayList<Item>(); SolrQuery params = new SolrQuery(solrQueryResolver.buildQuery(filters)) .setRows(length) .setStart(offset); SolrDocumentList solrDocuments = DSpaceSolrSearch.query(server, params); for (SolrDocument doc : solrDocuments) { list.add(new DSpaceSolrItem(doc)); } return new QueryResult(list, (solrDocuments.getNumFound() > offset + length), (int) solrDocuments.getNumFound()); }
public SolrDocumentListIterator(SolrDocumentList solrDocumentList) { this.solrDocumentIterator = solrDocumentList.iterator(); this.numFound = solrDocumentList.getNumFound(); // SolrQuery has the start field of type int while SolrDocumentList of // type long. We are always querying with an int so we can't receive a // long as output. That's the reason why the following cast seems safe this.start = (int) solrDocumentList.getStart(); this.size = solrDocumentList.size(); }
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); } }
@Override public ObjectCount queryTotal(String query, String filterQuery) throws SolrServerException { QueryResponse queryResponse = query(query, filterQuery, null, 0, -1, null, null, null, null, null, false); ObjectCount objCount = new ObjectCount(); objCount.setCount(queryResponse.getResults().getNumFound()); return objCount; }
public static ObjectCount queryTotal(String query, String filterQuery) throws SolrServerException { QueryResponse queryResponse = query(query, filterQuery, null, -1, null, null, null, null); ObjectCount objCount = new ObjectCount(); objCount.setCount(queryResponse.getResults().getNumFound()); return objCount; }
private long countDocs(SolrServer ontologiesSolrServer) throws SolrServerException { SolrQuery countQuery = new SolrQuery("*:*"); countQuery.setRows(0); QueryResponse queryResponse = ontologiesSolrServer.query(countQuery); long count = queryResponse.getResults().getNumFound(); return count; }
public long countAllDocuments(){ SolrQuery query = new SolrQuery("*:*"); query.setRows(0); try { return solrServer.query(query).getResults().getNumFound(); } catch (SolrServerException e) { throw new IntactSolrException("Problem searching with query: "+query, e); } }
@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); } }