List of usage examples for org.apache.solr.search DocSlice matches
long matches
To view the source code for org.apache.solr.search DocSlice matches.
Click Source Link
From source file:com.sn.solr.plugin.common.SolrHelper.java
License:Apache License
/** * Constructs {@link SolrDocumentList} from the current {@link SolrQueryRequest} * and {@link SolrQueryResponse}.//from w ww. j a v a 2 s.c o m * * @param req {@link SolrQueryRequest} * @param res {@link SolrQueryResponse} * @return * @throws CorruptIndexException * @throws IOException */ public static SolrDocumentList getSolrDocList(SolrQueryRequest req, SolrQueryResponse res) throws CorruptIndexException, IOException { DocSlice slice = (DocSlice) res.getValues().get(RESP_EL_TAG); Set<String> returnFields = SolrHelper.getReturnFields(req); SolrDocumentList docList = new SolrDocumentList(); for (DocIterator it = slice.iterator(); it.hasNext();) { int docId = it.nextDoc(); Document doc = req.getSearcher().getReader().document(docId); SolrDocument sdoc = new SolrDocument(); for (Fieldable f : doc.getFields()) { String fn = f.name(); if (returnFields.contains(fn)) { sdoc.addField(fn, doc.get(fn)); } } docList.add(sdoc); } docList.setMaxScore(slice.maxScore()); docList.setNumFound(slice.matches()); docList.setStart(slice.offset()); return docList; }
From source file:com.sn.solr.utils.common.SolrHelper.java
License:Apache License
/** * Constructs {@link SolrDocumentList} from the current {@link SolrQueryRequest} * and {@link SolrQueryResponse}./*w ww . j av a 2 s .co m*/ * * @param req {@link SolrQueryRequest} * @param res {@link SolrQueryResponse} * @return * @throws CorruptIndexException * @throws IOException */ public static SolrDocumentList getSolrDocList(SolrQueryRequest req, SolrQueryResponse res) throws CorruptIndexException, IOException { DocSlice slice = (DocSlice) res.getValues().get(RESP_EL_TAG); Set<String> returnFields = SolrHelper.getReturnFields(req); SolrDocumentList docList = new SolrDocumentList(); for (DocIterator it = slice.iterator(); it.hasNext();) { int docId = it.nextDoc(); Document doc = req.getSearcher().getReader().document(docId); SolrDocument sdoc = new SolrDocument(); for (Fieldable f : doc.getFields()) { String fn = f.name(); if (returnFields.contains(fn)) { sdoc.addField(fn, doc.get(fn)); } } docList.add(sdoc); } docList.setMaxScore(slice.maxScore()); docList.setNumFound(slice.matches()); return docList; }