# Mongodb with Elasticsearch: nested document

**URL:** <https://discuss.elastic.co/t/mongodb-with-elasticsearch-nested-document/17841>\
**Category:** Elasticsearch\
**Created:** [May 31, 2014, 10:42am UTC](https://discuss.elastic.co/t/mongodb-with-elasticsearch-nested-document/17841 "2014-05-31T10:42:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Udomsak\_Donkhampai](https://avatars.discourse-cdn.com/v4/letter/u/cc9497/32.png) [@Udomsak\_Donkhampai](https://discuss.elastic.co/u/Udomsak_Donkhampai)\
**Post date:** [May 31, 2014, 10:42am UTC](https://discuss.elastic.co/t/mongodb-with-elasticsearch-nested-document/17841/1 "2014-05-31T10:42:41Z")

</div>

Hi all,  
Now,I'm working with nested document in ES. by using mongo river for  
insert data.  
So, I just wander what is the best way to handle insert nested document.  
For example:  
{  
"name": "Multi G. Enre", "books": [ { "name": "Guns and lasers", "genre":  
"scifi", "publisher": "orbit" }, { "name": "Dead in the night", "genre":  
"thriller", "publisher": "penguin" } ] }  
this one is my document and books is nested document. So, when I want to  
add/insert book into this document . which mongo operation is the best  
solution for this to match with ES that in ES we can insert only nested  
document and link it to parent document.

So on, I can think only few ways.

1. just use $push operator to add new books(nested document).
2. use $set operator to reset every thing under books.

but I do not know that how mongo-river handle for this. I know that  
mongo-river support with nested document but not really sure that which way  
is the best for this scenario.

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/ee94e83d-7cdb-4db8-a619-7729524fa00d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ee94e83d-7cdb-4db8-a619-7729524fa00d%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:25am UTC](https://discuss.elastic.co/t/mongodb-with-elasticsearch-nested-document/17841/2 "2017-07-06T01:25:32Z")

</div>

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


