當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。