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


Java SolrDocument.getFieldValues方法代码示例

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


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

示例1: getLatestValidDateUpdated

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * Returns the latest DATEUPDATED value on the given <code>SolrDocument</code> that is no larger than <code>untilTimestamp</code>. Returns 0 if no
 * such value is found.
 * 
 * @param doc
 * @param untilTimestamp
 * @return Latest DATEUPDATED value is less than or equals untilTimestamp on doc; 0 if none found.
 * @should return correct value
 * @should return 0 if no valid value is found
 */
public static Long getLatestValidDateUpdated(SolrDocument doc, long untilTimestamp) {
    long ret = 0;
    Collection<Object> dateUpdatedValues = doc.getFieldValues(SolrConstants.DATEUPDATED);
    if (dateUpdatedValues != null && !dateUpdatedValues.isEmpty()) {
        // Get latest DATEUPDATED values
        for (Object o : dateUpdatedValues) {
            long dateUpdated = (Long) o;
            if (dateUpdated > ret && dateUpdated <= untilTimestamp) {
                ret = dateUpdated;
            }
        }
    }

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

示例2: prepareUpdate

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * Prepares the given record for an update. Creation timestamp is preserved. A new update timestamp is added, child docs are removed.
 * 
 * @param indexObj {@link IndexObject}
 * @throws IOException -
 * @throws SolrServerException
 * @throws FatalIndexerException
 */
private void prepareUpdate(IndexObject indexObj) throws IOException, SolrServerException, FatalIndexerException {
    String pi = indexObj.getPi().trim();
    SolrDocumentList hits = hotfolder.getSolrHelper().search(SolrConstants.PI + ":" + pi, null);
    if (hits != null && hits.getNumFound() > 0) {
        logger.debug("This file has already been indexed, initiating an UPDATE instead...");
        indexObj.setUpdate(true);
        SolrDocument doc = hits.get(0);
        // Set creation timestamp, if exists (should never be updated)
        Object dateCreated = doc.getFieldValue(SolrConstants.DATECREATED);
        if (dateCreated != null) {
            // Set creation timestamp, if exists (should never be updated)
            indexObj.setDateCreated((Long) dateCreated);
        }
        // Set update timestamp
        Collection<Object> dateUpdatedValues = doc.getFieldValues(SolrConstants.DATEUPDATED);
        if (dateUpdatedValues != null) {
            for (Object date : dateUpdatedValues) {
                indexObj.getDateUpdated().add((Long) date);
            }
        }
        // Recursively delete all children
        deleteWithPI(pi, false, hotfolder.getSolrHelper());
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:33,代码来源:LidoIndexer.java

示例3: getString

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * Safely gets a String for the given field.
 *
 * @param solrDocument the docoument to get the field from
 * @param field the field to get
 * @return the String value of the field
 */
default String getString(SolrDocument solrDocument, String field) {
    String returnVal = null;
    final Object object = solrDocument.getFieldValue(field);
    if (object != null) {
        if (object instanceof String) {
            returnVal = (String) object;
        } else if (object instanceof ArrayList) {
            Collection<Object> objects = solrDocument.getFieldValues(field);
            if (objects.size() > 0) {
                returnVal = (String) objects.iterator().next();
            }
        } else {
            returnVal = object.toString();
        }
    }
    return returnVal;
}
 
开发者ID:bbende,项目名称:tripod,代码行数:25,代码来源:SolrDocumentTransformer.java

示例4: generateEpicurHeader

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * generates header for epicur format
 * 
 * @param doc
 * @param dateUpdated
 * @return
 */
private static Element generateEpicurHeader(SolrDocument doc, long dateUpdated) {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element header = new Element("header", xmlns);
    Element identifier = new Element("identifier", xmlns);
    identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + (String) doc.getFieldValue(
            "URN"));
    header.addContent(identifier);

    Element datestamp = new Element("datestamp", xmlns);
    datestamp.setText(parseDate(dateUpdated));
    header.addContent(datestamp);
    // setSpec
    List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(Metadata.epicur.name());
    if (!setSpecFields.isEmpty()) {
        for (String setSpecField : setSpecFields) {
            if (doc.containsKey(setSpecField)) {
                for (Object fieldValue : doc.getFieldValues(setSpecField)) {
                    // TODO translation
                    Element setSpec = new Element("setSpec", xmlns);
                    setSpec.setText((String) fieldValue);
                    header.addContent(setSpec);
                }
            }
        }
    }
    // status="deleted"
    if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
        header.setAttribute("status", "deleted");
    }

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

示例5: generateEpicurPageHeader

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * 
 * @param doc
 * @param urn
 * @param dateUpdated
 * @return
 */
private static Element generateEpicurPageHeader(SolrDocument doc, String urn, long dateUpdated) {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element header = new Element("header", xmlns);

    Element identifier = new Element("identifier", xmlns);
    identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + urn);
    header.addContent(identifier);

    Element datestamp = new Element("datestamp", xmlns);
    datestamp.setText(parseDate(dateUpdated));
    header.addContent(datestamp);
    // setSpec
    List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(Metadata.epicur.name());
    if (!setSpecFields.isEmpty()) {
        for (String setSpecField : setSpecFields) {
            if (doc.containsKey(setSpecField)) {
                for (Object fieldValue : doc.getFieldValues(setSpecField)) {
                    // TODO translation
                    Element setSpec = new Element("setSpec", xmlns);
                    setSpec.setText((String) fieldValue);
                    header.addContent(setSpec);
                }
            }
        }
    }
    // status="deleted"
    if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
        header.setAttribute("status", "deleted");
    }

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

示例6: prepareUpdate

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * Prepares the given record for an update. Creation timestamp and representative thumbnail and anchor IDDOC are preserved. A new update timestamp
 * is added, child docs are removed.
 * 
 * @param indexObj {@link IndexObject}
 * @throws IOException
 * @throws SolrServerException
 * @throws FatalIndexerException
 * @should keep creation timestamp
 * @should set update timestamp correctly
 * @should keep representation thumbnail
 * @should keep anchor IDDOC
 * @should delete anchor secondary docs
 */
protected void prepareUpdate(IndexObject indexObj) throws IOException, SolrServerException, FatalIndexerException {
    String pi = indexObj.getPi().trim();
    SolrDocumentList hits = hotfolder.getSolrHelper().search(SolrConstants.PI + ":" + pi, null);
    if (hits != null && hits.getNumFound() > 0) {
        logger.debug("This file has already been indexed, initiating an UPDATE instead...");
        indexObj.setUpdate(true);
        SolrDocument doc = hits.get(0);
        // Set creation timestamp, if exists (should never be updated)
        Object dateCreated = doc.getFieldValue(SolrConstants.DATECREATED);
        if (dateCreated != null) {
            // Set creation timestamp, if exists (should never be updated)
            indexObj.setDateCreated((Long) dateCreated);
        }
        // Set update timestamp
        Collection<Object> dateUpdatedValues = doc.getFieldValues(SolrConstants.DATEUPDATED);
        if (dateUpdatedValues != null) {
            for (Object date : dateUpdatedValues) {
                indexObj.getDateUpdated().add((Long) date);
            }
        }
        // Set previous representation thumbnail, if available
        Object thumbnail = doc.getFieldValue(SolrConstants.THUMBNAILREPRESENT);
        if (thumbnail != null) {
            indexObj.setThumbnailRepresent((String) thumbnail);
        }

        // Recursively delete all children, if not an anchor
        deleteWithPI(pi, false, hotfolder.getSolrHelper());
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:45,代码来源:WorldViewsIndexer.java

示例7: getStrings

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * Safely gets an Set of Strings for the given field.
 *
 * @param solrDocument the document to get the field from
 * @param field the field to get
 * @return the strings values for the field
 */
default Set<String> getStrings(SolrDocument solrDocument, String field) {
    final Collection<Object> objects = solrDocument.getFieldValues(field);
    Set<String> strs = new HashSet<>();
    if (objects != null) {
        for (Object obj : objects) {
            strs.add((String) obj);
        }
    }
    return strs;
}
 
开发者ID:bbende,项目名称:tripod,代码行数:18,代码来源:SolrDocumentTransformer.java

示例8: getObject

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
@Override
public Collection<T> getObject() {
    final SolrDocument document = documentModel.getObject();
    if (document != null) {
        final Collection<Object> fieldValues = document.getFieldValues(fieldNameModel.getObject());
        if (fieldValues != null) {
            return transformCollectionType(fieldValues);
        }
    }
    return null;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:12,代码来源:SolrFieldModel.java

示例9: getHeader

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * create the header for listIdentifiers and ListRecords, because there are both the same
 * 
 * @param doc Document from which to extract values.
 * @param topstructDoc If not null, the datestamp value will be determined from this instead.
 * @return
 * @throws SolrServerException
 */
private Element getHeader(SolrDocument doc, SolrDocument topstructDoc, RequestHandler handler) throws SolrServerException {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element header = new Element("header", xmlns);
    // identifier
    if (doc.getFieldValue(SolrConstants.URN) != null && ((String) doc.getFieldValue(SolrConstants.URN)).length() > 0) {
        Element urn_identifier = new Element("identifier", xmlns);
        urn_identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + (String) doc
                .getFieldValue(SolrConstants.URN));
        header.addContent(urn_identifier);
    } else {
        Element identifier = new Element("identifier", xmlns);
        identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + (String) doc
                .getFieldValue(SolrConstants.PI));
        header.addContent(identifier);
    }
    // datestamp
    Element datestamp = new Element("datestamp", xmlns);
    long untilTimestamp = RequestHandler.getUntilTimestamp(handler.getUntil());
    long timestampModified = SolrSearchIndex.getLatestValidDateUpdated(topstructDoc != null ? topstructDoc : doc, untilTimestamp);
    datestamp.setText(parseDate(timestampModified));
    if (StringUtils.isEmpty(datestamp.getText()) && doc.getFieldValue(SolrConstants.ISANCHOR) != null) {
        datestamp.setText(parseDate(solr.getLatestVolumeTimestamp(doc, untilTimestamp)));
    }
    header.addContent(datestamp);
    // setSpec
    List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(handler.getMetadataPrefix()
            .name());
    if (!setSpecFields.isEmpty()) {
        for (String setSpecField : setSpecFields) {
            if (doc.containsKey(setSpecField)) {
                for (Object fieldValue : doc.getFieldValues(setSpecField)) {
                    // TODO translation
                    Element setSpec = new Element("setSpec", xmlns);
                    setSpec.setText((String) fieldValue);
                    header.addContent(setSpec);
                }
            }
        }
    }

    // status="deleted"
    if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
        header.setAttribute("status", "deleted");
    }

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

示例10: prepareUpdate

import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
 * Prepares the given record for an update. Creation timestamp and representative thumbnail and anchor IDDOC are preserved. A new update timestamp
 * is added, child docs are removed.
 * 
 * @param indexObj {@link IndexObject}
 * @throws IOException
 * @throws SolrServerException
 * @throws FatalIndexerException
 * @should keep creation timestamp
 * @should set update timestamp correctly
 * @should keep representation thumbnail
 * @should keep anchor IDDOC
 * @should delete anchor secondary docs
 */
protected void prepareUpdate(IndexObject indexObj) throws IOException, SolrServerException, FatalIndexerException {
    String pi = indexObj.getPi().trim();
    SolrDocumentList hits = hotfolder.getSolrHelper().search(SolrConstants.PI + ":" + pi, null);
    if (hits == null || hits.getNumFound() == 0) {
        return;
    }

    logger.debug("This file has already been indexed, initiating an UPDATE instead...");
    indexObj.setUpdate(true);
    SolrDocument doc = hits.get(0);
    // Set creation timestamp, if exists (should never be updated)
    Object dateCreated = doc.getFieldValue(SolrConstants.DATECREATED);
    if (dateCreated != null) {
        // Set creation timestamp, if exists (should never be updated)
        indexObj.setDateCreated((Long) dateCreated);
    }
    // Set update timestamp
    Collection<Object> dateUpdatedValues = doc.getFieldValues(SolrConstants.DATEUPDATED);
    if (dateUpdatedValues != null) {
        for (Object date : dateUpdatedValues) {
            indexObj.getDateUpdated().add((Long) date);
        }
    }
    // Set previous representation thumbnail, if available
    Object thumbnail = doc.getFieldValue(SolrConstants.THUMBNAILREPRESENT);
    if (thumbnail != null) {
        indexObj.setThumbnailRepresent((String) thumbnail);
    }
    if (isAnchor()) {
        // Keep old IDDOC
        indexObj.setIddoc(Long.valueOf(doc.getFieldValue(SolrConstants.IDDOC).toString()));
        // Delete old doc
        hotfolder.getSolrHelper().deleteDocument(String.valueOf(indexObj.getIddoc()));
        // Delete secondary docs (aggregated metadata, events)
        List<String> iddocsToDelete = new ArrayList<>();
        hits = hotfolder.getSolrHelper().search(SolrConstants.IDDOC_OWNER + ":" + indexObj.getIddoc(), Collections.singletonList(
                SolrConstants.IDDOC));
        for (SolrDocument doc2 : hits) {
            iddocsToDelete.add((String) doc2.getFieldValue(SolrConstants.IDDOC));
        }
        if (!iddocsToDelete.isEmpty()) {
            logger.info("Deleting {} secondary documents...", iddocsToDelete.size());
            hotfolder.getSolrHelper().deleteDocuments(new ArrayList<>(iddocsToDelete));
        }
    } else {
        // Recursively delete all children, if not an anchor
        deleteWithPI(pi, false, hotfolder.getSolrHelper());
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:64,代码来源:MetsIndexer.java


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