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


Java SolrDocumentList.size方法代码示例

本文整理汇总了Java中org.apache.solr.common.SolrDocumentList.size方法的典型用法代码示例。如果您正苦于以下问题:Java SolrDocumentList.size方法的具体用法?Java SolrDocumentList.size怎么用?Java SolrDocumentList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.common.SolrDocumentList的用法示例。


在下文中一共展示了SolrDocumentList.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
public static void main(String[] args) throws MalformedURLException, SolrServerException {
		String zkHost = "localhost:2181";
		String defaultCollection = "collection1";
		CloudSolrServer solr = new CloudSolrServer(zkHost);
		solr.setDefaultCollection(defaultCollection);
        
/*		ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("q", "cat:electronics");
    	params.set("defType", "edismax");
    	params.set("start", "0");*/
		
		SolrQuery params = new SolrQuery();
		params.setQuery("*:*");
		params.setSort("score ",ORDER.desc);
		params.setStart(Integer.getInteger("0"));
		params.setRows(Integer.getInteger("100"));
		
    

		QueryResponse response = solr.query(params);
		SolrDocumentList results = response.getResults();
		for (int i = 0; i < results.size(); ++i) {
			System.out.println(results.get(i));
		}
	}
 
开发者ID:dimensoft,项目名称:improved-journey,代码行数:26,代码来源:SolrCloudSolrJSearcher.java

示例2: main

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
public static void main(String[] args) throws MalformedURLException, SolrServerException {
		HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr");
//		  ModifiableSolrParams params = new ModifiableSolrParams(); 
//        params.setQuery("name:Samsung ");
//        params.setStart(0);
//        params.setRows(100);
		SolrQuery params = new SolrQuery();
		params.setQuery("*:*");
		params.setSort("score ",ORDER.desc);
		params.setStart(Integer.getInteger("0"));
		params.setRows(Integer.getInteger("100"));

		QueryResponse response = solr.query(params);
		SolrDocumentList results = response.getResults();
		for (int i = 0; i < results.size(); ++i) {
			System.out.println(results.get(i));
		}
	}
 
开发者ID:dimensoft,项目名称:improved-journey,代码行数:19,代码来源:SolrJSearcher.java

示例3: createListIdentifiers

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * for the server request ?verb=ListIdentifiers this method build the xml section
 * 
 * @param handler
 * @param firstRow
 * @param numRows
 * @return
 * @throws SolrServerException
 */
public Element createListIdentifiers(RequestHandler handler, int firstRow, int numRows) throws SolrServerException {
    Map<String, String> datestamp = filterDatestampFromRequest(handler);
    SolrDocumentList listIdentifiers = solr.getListIdentifiers(datestamp, firstRow, numRows, false);
    if (listIdentifiers == null || listIdentifiers.isEmpty()) {
        return new ErrorCode().getNoRecordsMatch();
    }

    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element xmlListIdentifiers = new Element("ListIdentifiers", xmlns);
    long totalHits = listIdentifiers.getNumFound();
    for (int i = 0; i < listIdentifiers.size(); i++) {
        SolrDocument doc = listIdentifiers.get(i);
        Element header = getHeader(doc, null, handler);
        xmlListIdentifiers.addContent(header);
    }

    // Create resumption token
    if (totalHits > firstRow + numRows) {
        Element resumption = createResumptionTokenAndElement(totalHits, firstRow + numRows, xmlns, handler);
        xmlListIdentifiers.addContent(resumption);
    }

    return xmlListIdentifiers;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:34,代码来源:XMLGeneration.java

示例4: buildRealTimeGetResult

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
public static GetResult buildRealTimeGetResult(QueryResponse response, RealTimeGet query, DocumentFactory factory) {
    final String DOC = "doc";

    long nResults = 0;
    List<Document> docResults = new ArrayList<>();

    final SolrDocumentList results = response.getResults();
    if(results != null && results.size() >0){
        docResults = buildResultList(results, null, factory, null);
        nResults = docResults.size();
    } else {
        final SolrDocument solrDoc = (SolrDocument)response.getResponse().get(DOC);
        if(solrDoc != null) {
            final SolrDocumentList solrDocuments = new SolrDocumentList();
            solrDocuments.add(solrDoc);
            docResults = buildResultList(solrDocuments, null, factory, null);
            nResults = 1;
        }
    }

    return new GetResult(nResults,docResults,query,factory);
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:23,代码来源:SolrUtils.java

示例5: getEarliestTimestamp

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
@Override
public Optional<Instant> getEarliestTimestamp() {
    String sortBy = getConfig().getString(getConfigPrefix() + "EarliestDatestamp.SortBy", "modified asc");
    String fieldName = getConfig().getString(getConfigPrefix() + "EarliestDatestamp.FieldName", "modified");
    String restriction = getConfig().getString(getConfigPrefix() + "Search.Restriction", null);
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.add(CommonParams.SORT, sortBy);
    params.add(CommonParams.Q, restriction);
    params.add(CommonParams.FQ, fieldName + ":[* TO *]");
    params.add(CommonParams.FL, fieldName);
    params.add(CommonParams.ROWS, "1");
    SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
    try {
        QueryResponse response = solrClient.query(params);
        SolrDocumentList list = response.getResults();
        if (list.size() >= 1) {
            Date date = (Date) list.get(0).getFieldValue(fieldName);
            return Optional.of(date.toInstant());
        }
    } catch (Exception exc) {
        LOGGER.error("Unable to handle solr request", exc);
    }
    return Optional.empty();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:25,代码来源:MCROAISolrSearcher.java

示例6: forEachRemaining

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
@Override
public void forEachRemaining(Consumer<? super SolrDocument> action) {
    if (action == null)
        throw new NullPointerException();
    ModifiableSolrParams p = new ModifiableSolrParams(params);
    p.set("rows", (int) rows);
    long start = this.start, size = estimateSize(), fetched = 0;
    while (fetched < size) {
        p.set("start", (int) (start + fetched));
        response = query(p);
        SolrDocumentList results = response.getResults();
        for (SolrDocument doc : results) {
            action.accept(doc);
        }
        fetched += results.size();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRSolrSearchUtils.java

示例7: deleteDocuments

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private boolean deleteDocuments() throws SolrServerException, IOException {
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q","*:*");
	params.add("rows", "100");
	QueryResponse queryResponse = solrServer.query(params);
	SolrDocumentList solrDocumentList = queryResponse.getResults();
	List<String> documentsToDelete = new ArrayList<String>();
	for(int i = 0; i < solrDocumentList.size(); i++) {
		documentsToDelete.add(solrDocumentList.get(i).getFirstValue("id").toString());
	}
	if(!documentsToDelete.isEmpty()) {
		solrServer.deleteById(documentsToDelete);
		solrServer.commit(true,true);
	}
	return queryResponse.getResults().getNumFound() > documentsToDelete.size();
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:17,代码来源:TestDataManager.java

示例8: assertFieldValues

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * Fails if the number of documents in the given SolrDocumentList differs
 * from the given number of expected values, or if any of the values in the
 * given field don't match the expected values in the same order.
 */
public static void assertFieldValues(SolrDocumentList documents, String fieldName, Object... expectedValues) {
  if (documents.size() != expectedValues.length) {
    fail("Number of documents (" + documents.size()
        + ") is different from number of expected values (" + expectedValues.length);
  }
  for (int docNum = 1 ; docNum <= documents.size() ; ++docNum) {
    SolrDocument doc = documents.get(docNum - 1);
    Object expected = expectedValues[docNum - 1];
    Object actual = doc.get(fieldName);
    if ((null == expected && null != actual) ||
        (null != expected && null == actual) ||
        (null != expected && null != actual && !expected.equals(actual))) {
      fail("Unexpected " + fieldName + " field value in document #" + docNum
          + ": expected=[" + expected + "], actual=[" + actual + "]");
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:SolrTestCaseJ4.java

示例9: distributeResponse

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private void distributeResponse(SolrDocumentList results, WorkLog workLog) {
  updateCount += results.size();
  RuleChangeUpdateManager manager = this;

  for (SolrDocument doc : results) {
    workLog.foundDocument();
    String id = (String) doc.getFieldValue(SolrEnum.ID.toString());
    synchronized (documents) {
      documents.add(id);
    }
    String deliveryUrl = (String) doc.getFieldValue(SolrEnum.DELIVERY_URL.toString());
    Date capture = (Date) doc.getFieldValue(SolrEnum.DATE.toString());
    float boost = (Float) doc.getFieldValue(SolrEnum.BOOST.toString());
    int ruleId = (Integer) doc.getFieldValue(SolrEnum.RULE.toString());
    Boolean deliverable = (Boolean) doc.getFieldValue(SolrEnum.DELIVERABLE.toString());
    Boolean discoverable = (Boolean) doc.getFieldValue(SolrEnum.DELIVERABLE.toString());
    DocumentStatus currentPolicy = DocumentStatus.status(deliverable, discoverable);
    RuleRecheckWorker worker = new RuleRecheckWorker(id, deliveryUrl, capture, ruleId, 
    		currentPolicy,boost, workLog, manager, restrictionsService);

    workProcessor.process(worker);
  }
}
 
开发者ID:nla,项目名称:bamboo,代码行数:24,代码来源:RuleChangeUpdateManager.java

示例10: 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);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:RealTimeGetComponent.java

示例11: assertExpandGroupCountAndOrder

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private void assertExpandGroupCountAndOrder(String group, int count, Map<String, SolrDocumentList>expandedResults, String... docs) throws Exception {
  SolrDocumentList results = expandedResults.get(group);
  if(results == null) {
    throw new Exception("Group Not Found:"+group);
  }

  if(results.size() != count) {
    throw new Exception("Expected Count "+results.size()+" Not Found:"+count);
  }

  for(int i=0; i<docs.length;i++) {
    String id = docs[i];
    SolrDocument doc = results.get(i);
    if(!doc.getFieldValue("id").toString().equals(id)) {
      throw new Exception("Id not in results or out of order:"+id+"!="+doc.getFieldValue("id"));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:DistributedExpandComponentTest.java

示例12: fetchPage

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
public Page<SolrQuery, SolrDocument> fetchPage(SolrQuery query) throws SolrServerException, IOException {
	SolrDocumentList documentList = this.fetchDocumentList(query);
	Optional<SolrQuery> next = Optional.empty();
	if (documentList.getStart() + documentList.size() < documentList.getNumFound()) {
		SolrQuery copy = query.getCopy();
		copy.setStart((int) (documentList.getStart() + documentList.size()));
		next = Optional.of(copy);
	}
	return new Page<>(next, documentList);
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:11,代码来源:Match.java

示例13: getDocument

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
@Override
public SolrDocument getDocument(String docId) {
    final SolrQuery query = queryFatory.createDocumentQuery(docId);
    final SolrDocumentList result = searchResultsDao.getDocuments(query);
    if (result.size() < 1) {
        return null;
    } else {
        logger.debug("Document with docId {} retrieved:", result);
        return result.get(0);
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:12,代码来源:SolrDocumentServiceImpl.java

示例14: getIds

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
List<Object> getIds(NamedList response) {
    List<Object> ids = new ArrayList<>();
    SolrDocumentList list = (SolrDocumentList) response.get("response");
    for (int j = 0; j < list.size(); ++j) {
        String id =  list.get(j).getFieldValue("id").toString();
        id = id.substring(id.indexOf(':')+1,id.length());
        ids.add(id);
    }

    return ids;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:12,代码来源:SolrSearchService.java

示例15: getItemByPid

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
@Override
public String getItemByPid(String identifier, User user, Locale locale){
	String title = "";
	
	QueryResponse response = solr.query(SOLRFIELD_Pid+":"+identifier, 
	                                    new Vector<String>(), 
	                                    new HashMap<String, String>(), 
	                                    parseAccessRights(user), 
	                                    new Vector<String>(), 
	                                    -1, -1, "score asc");
	if (response != null) {
		SolrDocumentList results = response.getResults();
		
		for (int i=0; i<results.size();i++) {
		    if (results.get(i).containsKey(SOLRFIELD_Title)) {
				title = convertToString(results.get(i).get(SOLRFIELD_Title), SOLRFIELD_Title);
			} else if (results.get(i).containsKey(SOLRFIELD_PreferredName) && title.equals("")) {
			    title = convertToString(results.get(i).get(SOLRFIELD_PreferredName), SOLRFIELD_PreferredName);
			}
		}
	}
	
	if (title.isEmpty() || title.equals("")) {
		title = new LocalizableMessage("header.notitlejs").getMessage(locale);
	}
	
	return title;
	
}
 
开发者ID:mikkeliamk,项目名称:osa,代码行数:30,代码来源:SolrManager.java


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