本文整理汇总了Java中org.apache.solr.common.SolrDocumentList.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java SolrDocumentList.iterator方法的具体用法?Java SolrDocumentList.iterator怎么用?Java SolrDocumentList.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.SolrDocumentList
的用法示例。
在下文中一共展示了SolrDocumentList.iterator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SolrDocumentListIterator
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
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();
}
示例2: nextBatch
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
public void nextBatch() throws TranslatorException {
SolrQuery query = this.visitor.getSolrQuery();
if (!this.visitor.isLimitInUse()) {
query.setStart(this.offset);
query.setRows(this.executionContext.getBatchSize());
}
QueryResponse queryResponse = connection.query(this.visitor.getSolrQuery());
SolrDocumentList docList = queryResponse.getResults();
this.resultSize = docList.getNumFound();
this.resultsItr = docList.iterator();
}
示例3: getNext
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private SolrDocument getNext(boolean forceFetch) {
if (forceFetch || !curPage.hasNext() && nextStart < numFound) {
//there is more
SolrDocumentList page = queryNext();
this.numFound = page.getNumFound();
this.nextStart += page.size();
this.curPage = page.iterator();
}
return count < limit && curPage.hasNext() ? curPage.next() : null;
}
示例4: getPageModel
import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
* 根据SolrServer与SolrQuery查询并获取FileModel
*
* @param solrServer, query。
* @return List<FileModel>
*/
public PageModel getPageModel(SolrServer solrServer, PageModel pageModel, SolrQuery query) {
List<FileModel> fileModels = new ArrayList<FileModel>();
try {
QueryResponse rsp = solrServer.query(query);
SolrDocumentList docs = rsp.getResults();
System.out.println("docs num:" + docs.getNumFound());
Map<String,Map<String,List<String>>> highlightMap=rsp.getHighlighting(); //获取所有高亮的字段
Iterator<SolrDocument> iter = docs.iterator();
while (iter.hasNext()) {
SolrDocument doc = iter.next();
// System.out.println("resource_name: " + doc.getFieldValue("resource_name").toString());
String type = getFileTypeName(doc.getFieldValue("content_type").toString());
String id = doc.getFieldValue("id").toString();
String name = doc.getFieldValue("file_name").toString();
String modifyTime = doc.getFieldValue("file_last_modified").toString();
// Date date = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US).parse(modifyTime);
// modifyTime = date.toLocaleString();//日期转换成如:2015-9-10 13:06:33
// System.out.println(doc.getFieldValue("last_modified"));
String author = null;
if(doc.getFieldValue("author") == null) {
author = "微软用户";
} else {
author = doc.getFieldValue("author").toString();
}
String indexTime = doc.getFieldValue("upload_time").toString();
String hdfsPath = doc.getFieldValue("file_path").toString();
String fileSize = doc.getFieldValue("file_length").toString();
FileModel fileModel = new FileModel();
fileModel.setId(id);
fileModel.setName(name);
fileModel.setType(type);
fileModel.setAuthor(author);
fileModel.setSize(fileSize);
fileModel.setModifyTime(modifyTime);
fileModel.setIndexTime(indexTime);
fileModel.setHdfsPath(hdfsPath);
List<String> titleList = highlightMap.get(id).get("file_name");
List<String> contentList = highlightMap.get(id).get("content_text");
//获取并设置高亮的字段title
if (titleList != null && titleList.size() > 0) {
fileModel.setHighlightName(titleList.get(0));
}
//获取并设置高亮的字段content
if (contentList != null && contentList.size() > 0) {
fileModel.setHighlightContent(contentList.get(0));
}
fileModels.add(fileModel);
}
pageModel.setDatas(fileModels);
pageModel.setCount(docs.getNumFound());
} catch (Exception e) {
log.error("从solr根据Page查询分页文档时遇到错误", e);
}
return pageModel;
}