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