本文整理汇总了Java中org.apache.solr.common.SolrDocument.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java SolrDocument.containsKey方法的具体用法?Java SolrDocument.containsKey怎么用?Java SolrDocument.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.SolrDocument
的用法示例。
在下文中一共展示了SolrDocument.containsKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDoc
import org.apache.solr.common.SolrDocument; //导入方法依赖的package包/类
/**
* Performs an atomic update of the given solr document. Updates defined in partialUpdates will be applied to the existing document without making
* any changes to other fields.
*
* @param doc
* @param partialUpdates Map of update operations (usage: Map<field, Map<operation, value>>)
* @return
* @throws FatalIndexerException
* @should update doc correctly
* @should add GROUPFIELD if original doc doesn't have it
*/
public boolean updateDoc(SolrDocument doc, Map<String, Map<String, Object>> partialUpdates) throws FatalIndexerException {
String iddoc = (String) doc.getFieldValue(SolrConstants.IDDOC);
SolrInputDocument newDoc = new SolrInputDocument();
newDoc.addField(SolrConstants.IDDOC, iddoc);
if (!doc.containsKey(SolrConstants.GROUPFIELD)) {
logger.warn("Document to update {} doesn't contain {} adding now.", iddoc, SolrConstants.GROUPFIELD);
Map<String, Object> update = new HashMap<>();
update.put("set", iddoc);
newDoc.addField(SolrConstants.GROUPFIELD, update);
}
for (String field : partialUpdates.keySet()) {
newDoc.addField(field, partialUpdates.get(field));
}
if (writeToIndex(newDoc)) {
commit(false);
return true;
}
return false;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}