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