当前位置: 首页>>代码示例>>Java>>正文


Java SolrDocumentList.iterator方法代码示例

本文整理汇总了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();
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:SolrEntityProcessor.java

示例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();
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:13,代码来源:SolrQueryExecution.java

示例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;
}
 
开发者ID:thammegowda,项目名称:solr-similarity,代码行数:11,代码来源:SolrDocIterator.java

示例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;
    }
 
开发者ID:hackty,项目名称:hadooptools,代码行数:73,代码来源:QueryFileServiceSolrMRImpl.java


注:本文中的org.apache.solr.common.SolrDocumentList.iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。