# When do you consider modeling some of the fields in a relational database vs ElasticSearch

**URL:** https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094
**Category:** Elasticsearch
**Created:** [May 21, 2019, 9:44pm UTC](https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094 "2019-05-21T21:44:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Anand\_Swaminathan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_swaminathan/32/45312_2.png) [@Anand\_Swaminathan](https://discuss.elastic.co/u/Anand_Swaminathan)
#### Post date: [May 21, 2019, 9:44pm UTC](https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094/1 "2019-05-21T21:44:20Z")

</div>

Hi,

I have a system similar to Blog Posts, comments, likes for posts and comments. I am considering modeling Blogs in ES and having data sync between Postgres system and ES when documents are updated. The Blog posts have comments and likes for posts and likes for comments.

I don't think there will be more than 50-100 concurrent users for now, but say in future 1000 concurrent users.

1. Because users can like comments and posts, the comments and posts may get updated frequently. Should I model comments as separate indexes because when I embed them within my posts (denormalization), the posts index will get reindexed every time I update the comments ?
2. Because comments and posts can have likes, should I model likes as a separate index since updating likes can cause comments and posts to be reindexed on every update ?

One of the reasons for the above question is that I plan on the UI to display the list of blog posts and clicking on a post shows the comments and likes .

Thanks for your insight into this.

---

<div class="post-metadata">

### Author: ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)
#### Post date: [May 22, 2019, 4:28am UTC](https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094/2 "2019-05-22T04:28:55Z")

</div>

Hi,

I can share about our experience using elastic from 2~3 years with contents like yours (Blogs, comments and like).

We denormalize data and store blog in a blog index, comments and likes in their respective monthly index.  
So far we didn't have any trouble or performance issue.  
Basically we use the comments and like as logs (Elastic is good for this 😁), one document for a like with a target\_related\_id (id of the blog or comment) and target\_kind (which can be blog or comment).  
After to display we make a get by id to get the blog detail and 1 multi\_search (i.e 1 request) for the comments and like (for the blog). You certainly need a third one if you have like on the comments.  
For the list i can be more complex depends on the order, as we sort by ranking (some complex formula based on the like comments tags etc...) we get the blog ids from this index then we get details in multi\_search.  
We also store blogs tags the same way and to get trend we aggregate... this one it depends on your needs.  
We also have views count stored the same way as like and comments, that we use for ranking.

So far the only problem is to have to manage ORM object and elastic json together, in our new application we remove database, only running with elastic. It remove some overhead as we use db only for storage but as we already have the data in elastic it become duplicate.

Hope it help you in your choice.

---

<div class="post-metadata">

### Author: ![Anand\_Swaminathan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_swaminathan/32/45312_2.png) [@Anand\_Swaminathan](https://discuss.elastic.co/u/Anand_Swaminathan)
#### Post date: [May 22, 2019, 5:39pm UTC](https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094/3 "2019-05-22T17:39:24Z")

</div>

Thanks Gabriel. A follow up question. How many blog posts, likes and comments did you have in each of the respective indexes ?

Thanks,  
AS

---

<div class="post-metadata">

### Author: ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)
#### Post date: [May 23, 2019, 3:36am UTC](https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094/4 "2019-05-23T03:36:37Z")

</div>

blogs: 740K doc /22Gb  
comments: 2.5 M doc /5Gb

like was removed between so index was deleted it was not so popular or maybe some people was cheating 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 20, 2019, 3:36am UTC](https://discuss.elastic.co/t/when-do-you-consider-modeling-some-of-the-fields-in-a-relational-database-vs-elasticsearch/182094/5 "2019-06-20T03:36:42Z")

</div>

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