# Elastic Search Design question

**URL:** <https://discuss.elastic.co/t/elastic-search-design-question/19797>\
**Category:** Elasticsearch\
**Created:** [September 15, 2014, 5:21pm UTC](https://discuss.elastic.co/t/elastic-search-design-question/19797 "2014-09-15T17:21:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taimoorkhan1](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@taimoorkhan1](https://discuss.elastic.co/u/taimoorkhan1)\
**Post date:** [September 15, 2014, 5:21pm UTC](https://discuss.elastic.co/t/elastic-search-design-question/19797/1 "2014-09-15T17:21:00Z")

</div>

Hi, I am trying to figure out how to best model my data in elasticsearch  
for the following scenario.

Scenario:  
Imagine a chat service which can have a number of participants (in tens of  
thousands). Messages are not pushed out to members but rather members can  
query for new messages based on which messages they have received so far.  
So we need to keep track of the last message sent to the channel and also  
the last message which each member has received. This comparison will  
allow us to determine if there are any new messages for this member.

The frequency of messages being sent is high (which may require frequent  
re-indexing and replica updates). I would also like to avoid double read  
i.e. read last message time from chat and then make another query

Possible models:

1. Nested objects. (Concern: is only root document is returned and not  
nested objects? Performance of re-indexing based on high frequency of  
udpates? Large replica updates between elastic search nodes).

2. Parent Child. (Would like to know more about this).

3. Sort of parent child without linking the documents with the '\_parent'  
property. So each member will keep track of both the last message sent to  
the chat as well as the last message they have seen so far. (Concern: a  
single message sent to a chat will required tens of thousands of updates to  
all its members).

4. A single large document with individual members nested inside.  
(Concern: The size of the document and frequency of updates will thrash  
the system?)

I would like to understand how elasticsearch can best model the above  
scenario or even if it is the right tool for this problem.

Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e7850f0a-25d3-4fd0-8595-a33ec38485d8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e7850f0a-25d3-4fd0-8595-a33ec38485d8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:02am UTC](https://discuss.elastic.co/t/elastic-search-design-question/19797/2 "2017-07-06T01:02:11Z")

</div>

Closed on July 6, 2017, 1:02am UTC


