本文整理汇总了Java中org.apache.solr.common.SolrDocumentList.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java SolrDocumentList.addAll方法的具体用法?Java SolrDocumentList.addAll怎么用?Java SolrDocumentList.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.SolrDocumentList
的用法示例。
在下文中一共展示了SolrDocumentList.addAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeResponses
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private void mergeResponses(ResponseBuilder rb) {
SolrDocumentList docList = new SolrDocumentList();
for (ShardRequest sreq : rb.finished) {
// if shards=shard1,shard2 was used, then we query both shards for each id and
// can get more than one response
for (ShardResponse srsp : sreq.responses) {
SolrResponse sr = srsp.getSolrResponse();
NamedList nl = sr.getResponse();
SolrDocumentList subList = (SolrDocumentList)nl.get("response");
docList.addAll(subList);
}
}
if (docList.size() <= 1 && rb.req.getParams().getParams("ids")==null) {
// if the doc was not found, then use a value of null.
rb.rsp.add("doc", docList.size() > 0 ? docList.get(0) : null);
} else {
docList.setNumFound(docList.size());
rb.rsp.add("response", docList);
}
}
示例2: mergeDistributedResultsIntSingleResponse
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private void mergeDistributedResultsIntSingleResponse(ResponseBuilder rb, List<AcGroupResult> resultsToMerge, String responseTagName) {
int docs = 0;
float maxScore = 0.0f;
// if groups have to be displayed in some custom order, other than the order specified in
// ac_grouping_field_def
String groupingSort = rb.req.getParams().get(AC_GROUPING_SORT_PARAM_NAME);
if (groupSorts.containsKey(groupingSort)) {
groupSorts.get(groupingSort).sort(rb, resultsToMerge);
}
SolrDocumentList docList = new SolrDocumentList();
// first find count of documents
for (AcGroupResult acGroupResult : resultsToMerge) {
// if slice contains more results than requested, take requested count; if it contains less results than
// requested, we have to take what we got, not more
docs += ((acGroupResult.getDistributedResultingDocs().size() > acGroupResult.getAcGroupingFieldValue().getRequestedCountOfSuggestions() == true) ?
acGroupResult.getAcGroupingFieldValue().getRequestedCountOfSuggestions() : acGroupResult.getDistributedResultingDocs().size());
if (acGroupResult.getDistributedResultingDocs().getMaxScore() > maxScore) {
maxScore = acGroupResult.getDistributedResultingDocs().getMaxScore();
}
docList.addAll(acGroupResult.getDistributedResultingDocs());
}
docList.setStart(0);
docList.setNumFound(docs);
rb.rsp.add(responseTagName, docList);
}
示例3: handleRequestBody
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
* Executes the user search request.
*
* @param req the solr query request
* @param rsp the solr query response holding the result
* @throws Exception if bad things happen
*/
@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
LOGGER.debug("Handling analysis request {}", req);
//First check if the request should return documents => rows > 0
String rowsParam = req.getParams().get(CommonParams.ROWS, null);
int rows = -1;
if (rowsParam != null) {
rows = Integer.parseInt(rowsParam);
}
SolrDocumentList results = new SolrDocumentList();
String[] chronixFunctions = req.getParams().getParams(ChronixQueryParams.CHRONIX_FUNCTION);
String chronixJoin = req.getParams().get(ChronixQueryParams.CHRONIX_JOIN);
//Do a query and collect them on the join function
JoinFunction key = new JoinFunction(chronixJoin);
Map<String, List<SolrDocument>> collectedDocs = collectDocuments(req, key);
//If no rows should returned, we only return the num found
if (rows == 0) {
results.setNumFound(collectedDocs.keySet().size());
} else {
//Otherwise return the analyzed time series
final TypeFunctions typeFunctions = QueryEvaluator.extractFunctions(chronixFunctions, TYPES, FUNCTIONS);
final List<SolrDocument> resultDocuments = analyze(req, typeFunctions, key, collectedDocs, !JoinFunction.isDefaultJoinFunction(key));
results.addAll(resultDocuments);
//As we have to analyze all docs in the query at once,
// the number of documents is also the number of documents found
results.setNumFound(resultDocuments.size());
}
//Add the results to the response
rsp.add("response", results);
}
示例4: readSolrDocumentList
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
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));
@SuppressWarnings("unchecked")
List<SolrDocument> l = (List<SolrDocument>) readVal(dis);
solrDocs.addAll(l);
return solrDocs;
}