本文整理匯總了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;
}