Simon
Simon

Reputation: 1117

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.

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. 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?

Upvotes: 0

Views: 58

Answers (1)

Ramzy
Ramzy

Reputation: 7138

Some questions to ask before you start designing. From solr perpective, you search for documents by giving a search term. 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.

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. let me know if you need any further information. Happy Designing and coding

Upvotes: 2

Related Questions