本文整理汇总了Java中org.apache.solr.common.SolrInputDocument.addChildDocuments方法的典型用法代码示例。如果您正苦于以下问题:Java SolrInputDocument.addChildDocuments方法的具体用法?Java SolrInputDocument.addChildDocuments怎么用?Java SolrInputDocument.addChildDocuments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.SolrInputDocument
的用法示例。
在下文中一共展示了SolrInputDocument.addChildDocuments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
@Override
public void write(Object source, Map sink) {
if (source == null) {
return;
}
SolrInputDocument convertedDocument = convert(source, SolrInputDocument.class);
sink.putAll(convertedDocument);
if (sink instanceof SolrInputDocument) {
SolrInputDocument parent = (SolrInputDocument) sink;
List<SolrInputDocument> childDocuments = convertedDocument.getChildDocuments();
if (childDocuments != null) {
parent.addChildDocuments(childDocuments);
}
}
}
示例2: toSolrInputDocument
import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
private SolrInputDocument toSolrInputDocument(Conversation conversation) {
boolean completed = conversation.getMeta().getStatus() == ConversationMeta.Status.Complete;
if(!completed){
return null; //do not index
}
final SolrInputDocument solrConversation = new SolrInputDocument();
solrConversation.setField(FIELD_ID, conversation.getId().toHexString());
//#150 index the current version of the index so that we can detect the need of a
//full re-index after a software update on startup
solrConversation.setField(FIELD_INDEX_VERSION, CONVERSATION_INDEX_VERSION);
solrConversation.setField(FIELD_TYPE, TYPE_CONVERSATION);
solrConversation.setField(FIELD_MODIFIED, conversation.getLastModified());
//add owner and context information
solrConversation.setField(FIELD_OWNER, conversation.getOwner().toHexString());
addContextFields(solrConversation, conversation);
solrConversation.setField(FIELD_MESSAGE_COUNT, conversation.getMessages().size());
if(!conversation.getMessages().isEmpty()) {
solrConversation.setField(FIELD_START_TIME, conversation.getMessages().get(0).getTime());
solrConversation.setField(FIELD_END_TIME, Iterables.getLast(conversation.getMessages()).getTime());
List<SolrInputDocument> messages = new ArrayList<>(conversation.getMessages().size());
Message prevMessage = null;
SolrInputDocument prevSolrInputDoc = null;
for (int i = 0; i < conversation.getMessages().size(); i++) {
final Message m = conversation.getMessages().get(i);
if (!m.isPrivate()) {
if ((prevMessage != null) && (prevSolrInputDoc != null)
// Same user
&& Objects.equals(m.getUser(), prevMessage.getUser())
// "same" user
&& Objects.equals(m.getOrigin(), prevMessage.getOrigin())
// within X seconds
&& m.getTime().before(DateUtils.addSeconds(prevMessage.getTime(), messageMergeTimeout))) {
// merge messages;
prevSolrInputDoc = mergeSolrUInputDoc(prevSolrInputDoc, toSolrInputDocument(m, i, conversation));
messages.remove(messages.size() - 1);
} else {
prevSolrInputDoc = toSolrInputDocument(m, i, conversation);
}
messages.add(prevSolrInputDoc);
prevMessage = m;
}
}
//we want the content of the messages also stored with the conversation (e.g. for highlighting)
messages.forEach(m -> solrConversation.addField(FIELD_MESSAGES, m.getFieldValues(FIELD_MESSAGE)));
solrConversation.addChildDocuments(messages);
}
return solrConversation;
}