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


Java SolrDocumentList.isEmpty方法代码示例

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


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

示例1: 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

示例2: getHeader

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
@Override
public Optional<Header> getHeader(String mcrId) {
    SolrQuery query = getBaseQuery(CommonParams.FQ);
    query.set(CommonParams.Q, "id:" + MCRSolrUtils.escapeSearchValue(mcrId));
    query.setRows(1);
    // do the query
    SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
    try {
        QueryResponse response = solrClient.query(query);
        SolrDocumentList results = response.getResults();
        if (!results.isEmpty()) {
            return Optional.of(toHeader(results.get(0), getSetResolver(results)));
        }
    } catch (Exception exc) {
        LOGGER.error("Unable to handle solr request", exc);
    }
    return Optional.empty();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:19,代码来源:MCROAISolrSearcher.java

示例3: printRanking

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * Ausgabe des Suchtreffer im Ranking
 * @param response
 */
private void printRanking(QueryResponse response) {
    if (response != null) {
        SolrDocumentList results = response.getResults();

        if (results.isEmpty()) {
            System.out.println("Ihre Suchanfrage ergab leider keine Treffer. Bitte modifizieren Sie ihre Anfrage.");
        }
        else {
            System.out.println("Trefferanzahl: " + results.getNumFound());
            System.out.println("~~~~~~~~~ Trefferliste ~~~~~~~");
            int rank = 1;
            for (SolrDocument doc : results) {
                System.out.println("Treffer #" + rank);
                System.out.println("\tID: " + doc.get("id"));
                System.out.println("\tTitel: " + doc.get("title"));

                // TODO weitere Indexfelder (mit stored=true) ausgeben

                System.out.println("\tScore: " + doc.get("score"));
                System.out.println("\n- - - - - - - - - - -");
                rank++;
            }
        }
    }
}
 
开发者ID:saschaszott,项目名称:suma-tech,代码行数:30,代码来源:SolrSearcher.java

示例4: assertQ

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
protected void assertQ(String query, int expectedCount, String... expectedFields)
    throws SolrServerException, IOException {

  SolrQuery solrQuery = new SolrQuery();
  solrQuery.setQuery(query);

  QueryResponse rsp = cloudSolrClient.query(solrQuery);
  SolrDocumentList docs = rsp.getResults();
  assertEquals(expectedCount, docs.size());
  log.info("docs: " + docs.toString());

  if (docs.isEmpty()) {
    fail("No results for query " + query);
  }

  SolrDocument doc = docs.get(0);
  if (expectedFields != null) {
    for (int counter = 0; counter < expectedFields.length; counter += 2) {
      assertTrue(
          doc.getFieldValue(expectedFields[counter]).toString() + " != " + expectedFields[counter
              + 1], doc.getFieldValue(expectedFields[counter]).toString()
              .equals(expectedFields[counter + 1]));
    }
  }
}
 
开发者ID:lucidworks,项目名称:solr-hadoop-common,代码行数:26,代码来源:SolrCloudClusterSupport.java

示例5: generateSearchRetrieve

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * 
 * @param parameter
 * @param request
 * @param solr
 * @return
 * @throws SolrServerException
 */
private static Element generateSearchRetrieve(SruRequestParameter parameter, HttpServletRequest request, SolrSearchIndex solr)
        throws SolrServerException {
    Element root = new Element("searchRetrieveResponse", SRU_NAMESPACE);
    Element version = new Element("version", SRU_NAMESPACE);
    version.setText(parameter.getVersion());
    root.addContent(version);

    String query = generateSearchQuery(parameter, request);
    QueryResponse queryResponse = solr.search(query, parameter.getStartRecord() - 1, parameter.getStartRecord() - 1 + parameter
            .getMaximumRecords(), null, null, null);
    SolrDocumentList solrDocuments = queryResponse.getResults();
    Element numberOfRecords = new Element("numberOfRecords", SRU_NAMESPACE);
    if (solrDocuments == null || solrDocuments.isEmpty()) {
        numberOfRecords.setText("0");
        logger.debug("Searched for {}, found {} documents.", query, 0);
    } else {
        numberOfRecords.setText(String.valueOf(solrDocuments.size()));
        logger.debug("Searched for {}, found {} documents.", query, solrDocuments.size());
    }
    root.addContent(numberOfRecords);

    Element records = new Element("records", SRU_NAMESPACE);
    root.addContent(records);

    generateRecords(records, solrDocuments, parameter, request, solr);
    generateEchoedSearchRetrieveRequest(root, solrDocuments, parameter);

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

示例6: getAnchorTitle

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
private static String getAnchorTitle(SolrDocument doc, SolrSearchIndex solr) throws SolrServerException {
    String iddocParent = (String) doc.getFieldValue(SolrConstants.IDDOC_PARENT);
    SolrDocumentList hits = solr.search(SolrConstants.IDDOC + ":" + iddocParent);
    if (hits != null && !hits.isEmpty()) {
        return (String) hits.get(0).getFirstValue("MD_TITLE");
    }

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

示例7: getAnchorTitle

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * 
 * @param doc
 * @return
 */
private String getAnchorTitle(SolrDocument doc) {
    String iddocParent = (String) doc.getFieldValue(SolrConstants.IDDOC_PARENT);
    try {
        SolrDocumentList hits = solr.search(SolrConstants.IDDOC + ":" + iddocParent);
        if (hits != null && !hits.isEmpty()) {
            return (String) hits.get(0).getFirstValue(SolrConstants.TITLE);
        }
    } catch (SolrServerException e) {
        logger.error(e.getMessage(), e);
    }

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

示例8: checkAndCreateGroupDoc

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * 
 * @param groupIdField Field name of the group identifier.
 * @param groupId Field value of the group identifier.
 * @param metadata Map with additional metadat fields to add to the group document.
 * @param iddoc IDDOC for the new document.
 * @return Group SolrInputDocument, if created.
 * @should create new document with all values if none exists
 * @should create updated document with all values if one already exists
 */
public SolrInputDocument checkAndCreateGroupDoc(String groupIdField, String groupId, Map<String, String> metadata, long iddoc) {
    try {
        SolrDocumentList docs = search(SolrConstants.PI + ":" + groupId, null);
        SolrInputDocument doc = new SolrInputDocument();
        Date now = new Date();
        if (docs.isEmpty()) {
            // Document does not exist yet
            doc.setField(SolrConstants.IDDOC, String.valueOf(iddoc));
            doc.setField(SolrConstants.GROUPFIELD, String.valueOf(iddoc));
            doc.setField(SolrConstants.DOCTYPE, DocType.GROUP.name());
            doc.setField(SolrConstants.DATECREATED, now.getTime());
        } else {
            // A document already exists for this groupId
            SolrDocument oldDoc = docs.get(0);
            doc.setField(SolrConstants.IDDOC, oldDoc.getFieldValue(SolrConstants.IDDOC));
            if (doc.getField(SolrConstants.GROUPFIELD) == null) {
                doc.setField(SolrConstants.GROUPFIELD, oldDoc.getFieldValue(SolrConstants.IDDOC));
            }
            doc.setField(SolrConstants.DOCTYPE, DocType.GROUP.name());
            doc.setField(SolrConstants.DATECREATED, oldDoc.getFieldValue(SolrConstants.DATECREATED));
        }
        doc.setField(SolrConstants.DATEUPDATED, now.getTime());
        doc.setField(SolrConstants.PI, groupId);
        doc.setField(SolrConstants.PI_TOPSTRUCT, groupId);
        doc.setField(SolrConstants.GROUPTYPE, groupIdField);
        if (metadata != null) {
            for (String fieldName : metadata.keySet()) {
                String fieldValue = metadata.get(fieldName);
                doc.setField(fieldName, fieldValue);
            }
        }
        return doc;
    } catch (SolrServerException e) {
        logger.error(e.getMessage(), e);
    }

    return null;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:49,代码来源:SolrHelper.java

示例9: updateAllAnchorChildren

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/***
 * Re-indexes all child records of the given anchor document.
 * 
 * @param indexObj {@link IndexObject}
 * @throws IOException -
 * @throws SolrServerException
 */
private void updateAllAnchorChildren(IndexObject indexObj) throws IOException, SolrServerException {
    logger.debug("Scheduling all METS files that belong to this anchor for re-indexing...");
    SolrDocumentList hits = hotfolder.getSolrHelper().search(new StringBuilder(SolrConstants.PI_PARENT).append(":").append(indexObj.getPi())
            .append(" AND ").append(SolrConstants.ISWORK).append(":true").toString(), null);
    if (hits.isEmpty()) {
        logger.debug("No volume METS files found for this anchor.");
        return;
    }
    for (SolrDocument doc : hits) {
        // Do not use PI here, as older documents might not have that field, use PPN instead
        String pi = doc.getFieldValue(SolrConstants.PI).toString();
        if (doc.getFieldValue(SolrConstants.IDDOC_PARENT) != null && doc.getFieldValue(SolrConstants.IDDOC_PARENT).toString().equals(String
                .valueOf(indexObj.getIddoc()))) {
            logger.debug("{} already has the correct parent, skipping.", pi);
            continue;
        }
        // String indexedMetsFilePath = URLEncoder.encode(Hotfolder.getIndexedMets() + File.separator + pi + AbstractIndexer.XML_EXTENSION, "utf-8");
        String indexedMetsFilePath = dataRepository.getDir(DataRepository.PARAM_INDEXED_METS) + File.separator + pi
                + AbstractIndexer.XML_EXTENSION;
        Path indexedMets = Paths.get(indexedMetsFilePath);
        if (Files.exists(indexedMets)) {
            hotfolder.getReindexQueue().add(indexedMets);
            MetsIndexer.reindexedChildrenFileList.add(indexedMets);
            logger.debug("Added '{}' to reindexedChildrenPiList.", pi);
        }
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:35,代码来源:MetsIndexer.java

示例10: testSearch

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
@Override
public boolean testSearch() {
    boolean status = false;

    QueryResponse response = solr.query("*:*", new Vector<String>(), new HashMap<String, String>(), null, null, -1, -1, " ");
    if (response != null) {
        SolrDocumentList results = response.getResults();
        
        if (!results.isEmpty()) {
            status = true;
        }
    }
    
    return status;
}
 
开发者ID:mikkeliamk,项目名称:osa,代码行数:16,代码来源:SolrManager.java

示例11: getListRecord

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * Searches for identifier and return {@link SolrDocument} identifier can be PPN or URN (doc or page)
 * 
 * @param identifier Identifier to search
 * @param metadataPrefix
 * @return {@link SolrDocument}
 * @throws IOException
 * @throws SolrServerException
 */
public SolrDocument getListRecord(final String identifier, String metadataPrefix) throws IOException, SolrServerException {
    SolrDocumentList ret = query(identifier, metadataPrefix, 1);
    if (!ret.isEmpty()) {
        return ret.get(0);
    }

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

示例12: createListRecordsDC

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * for the server request ?verb=ListRecords this method build the xml section if metadataPrefix is oai_dc
 * 
 * @param handler
 * @param firstRow
 * @param numRows
 * @return
 * @throws SolrServerException
 */
public Element createListRecordsDC(RequestHandler handler, int firstRow, int numRows) throws SolrServerException {
    SolrDocumentList records = solr.getListRecords(filterDatestampFromRequest(handler), firstRow, numRows, false,
            getAdditionalDocstructsQuerySuffix(DataManager.getInstance().getConfiguration().getAdditionalDocstructTypes()));
    if (records.isEmpty()) {
        return new ErrorCode().getNoRecordsMatch();
    }
    return generateDC(records, records.getNumFound(), firstRow, numRows, handler, "ListRecords");
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:18,代码来源:XMLGeneration.java

示例13: createListRecordsESE

import org.apache.solr.common.SolrDocumentList; //导入方法依赖的package包/类
/**
 * for the server request ?verb=ListRecords this method build the xml section if metadataPrefix is oai_dc
 * 
 * @param handler
 * @param firstRow
 * @param numRows
 * @return
 * @throws SolrServerException
 */
public Element createListRecordsESE(RequestHandler handler, int firstRow, int numRows) throws SolrServerException {
    SolrDocumentList records = solr.getListRecords(filterDatestampFromRequest(handler), firstRow, numRows, false,
            getAdditionalDocstructsQuerySuffix(DataManager.getInstance().getConfiguration().getAdditionalDocstructTypes()));
    if (records.isEmpty()) {
        return new ErrorCode().getNoRecordsMatch();
    }
    return generateESE(records, records.getNumFound(), firstRow, numRows, handler, "ListRecords");
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:18,代码来源:XMLGeneration.java


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