本文整理汇总了Java中org.apache.solr.common.SolrInputDocument.getField方法的典型用法代码示例。如果您正苦于以下问题:Java SolrInputDocument.getField方法的具体用法?Java SolrInputDocument.getField怎么用?Java SolrInputDocument.getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.SolrInputDocument
的用法示例。
在下文中一共展示了SolrInputDocument.getField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAndCreateGroupDoc
import org.apache.solr.common.SolrInputDocument; //导入方法依赖的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;
}
示例2: addPageDoc
import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
@Override
public void addPageDoc(SolrInputDocument doc) {
String iddoc = String.valueOf(doc.getFieldValue(SolrConstants.IDDOC));
if (doc.getField(SolrConstants.FULLTEXT) != null) {
String text = (String) doc.getFieldValue(SolrConstants.FULLTEXT);
try {
FileUtils.writeStringToFile(new File(tempFolder.toFile(), iddoc + "_" + SolrConstants.FULLTEXT), text, ENCODING_UTF8);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
doc.removeField(SolrConstants.FULLTEXT);
}
if (save(doc, iddoc)) {
int order = (int) doc.getFieldValue(SolrConstants.ORDER);
if (pageDocOrderIddocMap.get(order) != null) {
logger.error("Collision for page order {}", order);
}
pageDocOrderIddocMap.put(order, iddoc);
if (pageDocFileNameIddocMap.get(doc.getFieldValue(SolrConstants.FILENAME)) != null) {
logger.warn("A doc already exists for file: {}", doc.getFieldValue(SolrConstants.FILENAME));
}
pageDocFileNameIddocMap.put((String) doc.getFieldValue(SolrConstants.FILENAME), iddoc);
pageDocPhysIdIddocMap.put((String) doc.getFieldValue(SolrConstants.PHYSID), iddoc);
pageDocsCounter.incrementAndGet();
logger.debug("Page docs added: {}", pageDocsCounter);
}
}