public long getStart() { return docs.getStart(); }
public long getStart() { return docs.getStart(); }
/** * Returns the start index (offset).<p> * * @return the start */ public Long getStart() { return new Long(m_resultDocuments.getStart()); }
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); }
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 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(); }
final SolrDocumentList solrDocumentList = queryResponse.getResults(); final Long numFound = solrDocumentList.getNumFound(); final Long start = solrDocumentList.getStart(); solrDocumentListNumFound = numFound.intValue(); solrDocumentListStart = start.intValue();
public PageTool(SolrQueryRequest request, SolrQueryResponse response) { String rows = request.getParams().get("rows"); if (rows != null) { results_per_page = new Integer(rows); } Object docs = response.getValues().get("response"); if (docs != null) { if (docs instanceof DocSlice) { DocSlice doc_slice = (DocSlice) docs; results_found = doc_slice.matches(); start = doc_slice.offset(); } else { SolrDocumentList doc_list = (SolrDocumentList) docs; results_found = doc_list.getNumFound(); start = doc_list.getStart(); } } page_count = (int) Math.ceil(results_found / (double) results_per_page); current_page_number = (int) Math.ceil(start / (double) results_per_page) + (page_count > 0 ? 1 : 0); }
HttpSolrServer httpSolrServer = new HttpSolrServer("http://localhost:8983/solr/collectionname/"); QueryResponse response = httpSolrServer.query(new SolrQuery(), METHOD.POST); SolrDocumentList solrDocumentList = queryResponse.getResults(); solrDocumentList.getNumFound(); solrDocumentList.getStart();
private static <T extends IsIndexed> IndexResult<T> queryResponseToIndexResult(QueryResponse response, Class<T> responseClass, Facets facets, List<String> liteFields) throws GenericException, NotSupportedException { final SolrDocumentList docList = response.getResults(); final List<FacetFieldResult> facetResults = processFacetFields(facets, response.getFacetFields()); final long offset = docList.getStart(); final long limit = docList.size(); final long totalCount = docList.getNumFound(); final List<T> docs = new ArrayList<>(); for (SolrDocument doc : docList) { docs.add(SolrCollectionRegistry.fromSolrDocument(responseClass, doc, liteFields)); } return new IndexResult<>(offset, limit, totalCount, docs, facetResults); }
@Override public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException { SolrDocumentList solrDocs = new SolrDocumentList(); List list = (List) readVal(dis); solrDocs.setNumFound((Long) list.get(0)); solrDocs.setStart((Long) list.get(1)); solrDocs.setMaxScore((Float) list.get(2)); callback.streamDocListInfo( solrDocs.getNumFound(), solrDocs.getStart(), solrDocs.getMaxScore() ); // Read the Array tagByte = dis.readByte(); if( (tagByte >>> 5) != (ARR >>> 5) ) { throw new RuntimeException( "doclist must have an array" ); } int sz = readSize(dis); for (int i = 0; i < sz; i++) { // must be a SolrDocument readVal( dis ); } return solrDocs; } };) {
@Override public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException { SolrDocumentList solrDocs = new SolrDocumentList(); List list = (List) readVal(dis); solrDocs.setNumFound((Long) list.get(0)); solrDocs.setStart((Long) list.get(1)); solrDocs.setMaxScore((Float) list.get(2)); callback.streamDocListInfo( solrDocs.getNumFound(), solrDocs.getStart(), solrDocs.getMaxScore() ); // Read the Array tagByte = dis.readByte(); if( (tagByte >>> 5) != (ARR >>> 5) ) { throw new RuntimeException( "doclist must have an array" ); } int sz = readSize(dis); for (int i = 0; i < sz; i++) { // must be a SolrDocument readVal( dis ); } return solrDocs; } };
public PageTool(SolrQueryRequest request, SolrQueryResponse response) { String rows = request.getParams().get("rows"); if (rows != null) { results_per_page = Integer.parseInt(rows); } //TODO: Handle group by results Object docs = response.getResponse(); if (docs != null) { if (docs instanceof DocSlice) { results_found = ((DocSlice) docs).matches(); start = ((DocSlice) docs).offset(); } else if(docs instanceof ResultContext) { DocList dl = ((ResultContext) docs).getDocList(); results_found = dl.matches(); start = dl.offset(); } else if(docs instanceof SolrDocumentList) { SolrDocumentList doc_list = (SolrDocumentList) docs; results_found = doc_list.getNumFound(); start = doc_list.getStart(); } else { throw new SolrException(SolrException.ErrorCode.UNKNOWN, "Unknown response type "+docs+". Expected one of DocSlice, ResultContext or SolrDocumentList"); } } page_count = (int) Math.ceil(results_found / (double) results_per_page); current_page_number = (int) Math.ceil(start / (double) results_per_page) + (page_count > 0 ? 1 : 0); }
public boolean compareSolrDocumentList(Object expected, Object actual) { if (!(expected instanceof SolrDocumentList) || !(actual instanceof SolrDocumentList)) { return false; } if (expected == actual) { return true; } SolrDocumentList list1 = (SolrDocumentList) expected; SolrDocumentList list2 = (SolrDocumentList) actual; if (list1.getMaxScore() == null) { if (list2.getMaxScore() != null) { return false; } } else if (list2.getMaxScore() == null) { return false; } else { if (Float.compare(list1.getMaxScore(), list2.getMaxScore()) != 0 || list1.getNumFound() != list2.getNumFound() || list1.getStart() != list2.getStart()) { return false; } } for(int i=0; i<list1.getNumFound(); i++) { if(!compareSolrDocument(list1.get(i), list2.get(i))) { return false; } } return true; }
private NodeInfo getNextDocument (SolrDocumentList docs) { // FIXME: test pagination I think there is a bug here if w/start > 0? SolrDocument doc = docs.get(position++ - (int) docs.getStart()); String uri = (String) doc.getFirstValue(uriFieldName); Object oxml = doc.getFirstValue(xmlFieldName); Long id = (Long) doc.getFirstValue(idFieldName); if (id == null) { // try to support migrating an old index? throw new LuxException("This index has no lux docids: it cannot support Lux on Solr Cloud"); } String xml = (String) ((oxml instanceof String) ? oxml : null); byte [] bytes = (byte[]) ((oxml instanceof byte[]) ? oxml : null); XdmNode node = eval.getDocReader().createXdmNode(id, uri, xml, bytes); DocumentInfo docNode = node.getUnderlyingNode().getDocumentRoot(); docNode.setUserData(SolrDocument.class.getName(), doc); return docNode; }
/** * Map solr query response to search results. * * @param queryResponse * the query response * @return the search results * */ public FulltextSearchResults mapSolrToSearchResults(final QueryResponse queryResponse) { if (queryResponse == null) { throw new GeneralServiceException("Null QueryResponse given."); } final SolrDocumentList responseDocumentList = queryResponse.getResults(); final Float maxScore = getMaxScoreToNormalize(responseDocumentList); if (LOG.isTraceEnabled()) { LOG.trace("Mapping response: {}", queryResponse); } final Map<String, Map<String, List<String>>> highlighting = queryResponse.getHighlighting(); final Iterator<SolrDocument> i = responseDocumentList.iterator(); // collect results final List<FulltextSearchResult> results = collectSearchResults(i, highlighting, maxScore); // create search results object String cursorMark = queryResponse.getNextCursorMark(); final FulltextSearchResults searchResults = new FulltextSearchResultsImpl(results, (int) responseDocumentList.getStart(), (int) responseDocumentList.getNumFound(), cursorMark); // add facet info searchResults.setFacetResult(FacetBuilder.mapFacetResult(queryResponse)); return searchResults; }
throw new XPathException ("Solr query response unexpectedly of type " + results.getClass().getName()); if (position < docs.getStart() + docs.size()) { return getNextDocument (docs);
writeMapSeparator(); writeKey("start",false); writeLong(null,docs.getStart());