简体   繁体   English

如何在Solr搜索引擎中存储此信息?

[英]How to store this information in the Solr search engine?

I built a communicator, and now I want to add the Solr search engine to it. 我建立了一个交流器,现在我想向其中添加Solr搜索引擎。

Users create conversations, and every single conversation contains one or more messages. 用户创建对话,每个对话都包含一个或多个消息。 Messages are store as nodes in a tree. 消息存储为树中的节点。 For example: 例如:

1. initial message
   1.1 reply
   1.2 another reply for initial message
      1.2.1 bla bla bla...
      1.2.2 Lorem ipsum dolorem...
   1.3 third reply for initial message

There is always exactly one initial message. 始终只有一个初始消息。

I want to store in Solr content of all messages. 我想在Solr中存储所有消息的内容。 I'm thinking about store data in this way: 我正在考虑以这种方式存储数据:

{
    "conversationId_s_lower": <conversation id here>,
    "messageId_s_lower": <message id here>,
    "content_txt_en": <message content here>
  }

But I need to index and make searching also in properties of conversation: 但是我需要在对话的属性中建立索引并进行搜索:

{
    conversationTitle_txt_en: "...",
    conversationAccessUsersId: [123, 45, ...],
    ....
}

So the question is: how should I index this data, and how should I make queries? 所以问题是:我应该如何为这些数据建立索引,以及如何进行查询?

Some questions to ask before you start designing. 在开始设计之前要问一些问题。 From solr perpective, you search for documents by giving a search term. 您可以从solr的角度给出搜索词来搜索文档。 So in your case, what do you consider a document to be. 因此,根据您的情况,您认为文档是什么。 Is it the conversation or an individual message. 是对话还是个人信息。 Mostly a document is analogous to entity. 通常,文档类似于实体。 So here I suppose a conversation. 所以在这里我想进行一次对话。 So it has an ID. 因此它具有一个ID。

Next is each conversation is having multiple messages. 接下来是每个对话都有多个消息。 I can see there are multiple levels to this message hierarchy. 我可以看到此消息层次结构有多个级别。 Do you want to maintain that? 您要维持吗? Or is it that all messages are considered to be under one level. 还是所有消息都被认为在一个级别之下。

Then querying part - When you search, are you expecting messages or conversations count. 然后查询部分-搜索时,您期望消息或对话计数吗? This is decided anyways when you design entity as above. 无论如何,当您如上所述设计实体时,这都是决定的。

Once you answer these questions, you can move to denormalizing or nested entities(in your case messages are nested under converations). 回答这些问题后,您可以转到非规范化或嵌套实体(在您的情况下,消息嵌套在聚合条件下)。 With answers to the above, the rest of the process can be found on any solr article to index documents. 通过上述回答,可以在所有Solr文章中找到其余过程以对文档建立索引。 let me know if you need any further information. 让我知道您是否需要任何进一步的信息。 Happy Designing and coding 快乐的设计和编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM