当前位置: 首页>>代码示例>>Java>>正文


Java SolrInputDocument.addChildDocuments方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:20,代码来源:MySolrJConverter.java

示例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;
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:56,代码来源:ConversationIndexer.java


注:本文中的org.apache.solr.common.SolrInputDocument.addChildDocuments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。