Nested document or separate index

Hi
I want to use elasticsearch in our company. The usage is as following:
We have million of influencers and each influencers have 1000s of posts just like instagram. I have 2 use cases:

  1. Search among these posts and get the influencers for those posts
  2. Search among this influencers on basis of their name and other fields.

What would be the best design for elasticsearch. I have 3 options in mind, need to choose 1.

  1. Create separate indexes for posts and influencer
  2. Create posts index and keep influencers as nested in those posts. (In this case, we need to update influencer data whenever some metric of influencer is changed)
  3. Create influencer index and keep posts as nested in the same document.

Please help me out which would give optimum results. Or any other design which may complete my usecase.

You can also try flattening the documents.
If you are trying to maintain the relationship then you can go with nested i.e for each influencer having multiple post or else you can go with flattening which will help in faster performance.

@Dasher
What do you mean by flattening the documents?
Suppose i have fields like:

posts: 
{
    "likes": 2300,
    "comments": 132,
    "captions": "Hi, I am caption",
    ....
}

influencer::
{
    "name": "Jane doe",
    "followers": 134000,
    "bio": "Hi, i m jane doe"
    ....
}

How would the resultant document will look like.
I want to query and create filters for all fields like like, comment, captions, name, bio, followers, etc

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.