# Simple Array Example

**URL:** <https://discuss.elastic.co/t/simple-array-example/19677>\
**Category:** Elasticsearch\
**Created:** [September 9, 2014, 10:39am UTC](https://discuss.elastic.co/t/simple-array-example/19677 "2014-09-09T10:39:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EzCocos](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EzCocos](https://discuss.elastic.co/u/EzCocos)\
**Post date:** [September 9, 2014, 10:39am UTC](https://discuss.elastic.co/t/simple-array-example/19677/1 "2014-09-09T10:39:50Z")

</div>

Dear All,  
I am trying to upload via a river to Elasticsearch some MySQL data which  
look like this:  
product\_id product\_info\_id  
'1' 1  
'1' 2  
'2' 3  
'2' 4

I am looking to have in Elasticsearch for this example 2 documents with \_id  
'1' and '2' containing each an array of product\_info\_id.

I have been struggling with this for days, I get either 4 documents or 2  
documents stored and 2 deleted. The mapping I used so far is this:  
{  
"product\_merchant" : {  
"\_source" : { "enabled" : false },  
"\_id" : { "path" : "product\_id" },  
"properties" : {  
"product\_infos" : {  
"properties" : {  
"product\_info\_id" : { "type" : "integer", "store" : "yes" }  
}  
}  
}  
}  
}

Could anyone help me to correct my mapping and/or provide some array  
examples?

Many thanks in advance,  
jm

--  
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/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 9, 2014, 12:01pm UTC](https://discuss.elastic.co/t/simple-array-example/19677/2 "2014-09-09T12:01:38Z")

</div>

Hello ,

Is product\_id unique , seems to me its not.  
In that case why have you made it as \_id.  
\_id should be unique and in face of dedupe , it would be over written.  
So remove defenition of \_id should solve the issue.

Thanks  
Vineeth

On Tue, Sep 9, 2014 at 4:09 PM, EzCocos [jmdepinay@gmail.com](mailto:jmdepinay@gmail.com) wrote:

> Dear All,  
> I am trying to upload via a river to Elasticsearch some MySQL data which  
> look like this:  
> product\_id product\_info\_id  
> '1' 1  
> '1' 2  
> '2' 3  
> '2' 4
> 
> I am looking to have in Elasticsearch for this example 2 documents with  
> \_id '1' and '2' containing each an array of product\_info\_id.
> 
> I have been struggling with this for days, I get either 4 documents or 2  
> documents stored and 2 deleted. The mapping I used so far is this:  
> {  
> "product\_merchant" : {  
> "\_source" : { "enabled" : false },  
> "\_id" : { "path" : "product\_id" },  
> "properties" : {  
> "product\_infos" : {  
> "properties" : {  
> "product\_info\_id" : { "type" : "integer", "store" : "yes" }  
> }  
> }  
> }  
> }  
> }
> 
> Could anyone help me to correct my mapping and/or provide some array  
> examples?
> 
> Many thanks in advance,  
> jm
> 
> --  
> 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/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5nyKqodCq9HG4V3k47m6kiAYfQuNSsvteYKLF2n1CLhRA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nyKqodCq9HG4V3k47m6kiAYfQuNSsvteYKLF2n1CLhRA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![EzCocos](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EzCocos](https://discuss.elastic.co/u/EzCocos)\
**Post date:** [September 9, 2014, 1:08pm UTC](https://discuss.elastic.co/t/simple-array-example/19677/3 "2014-09-09T13:08:25Z")

</div>

Many thanks Vineeth for your help.

product\_id is indeed unique. If I remove \_id I get 4 documents rather than  
2 documents containing each an array of related product\_info\_id.

I guess I want \_id to be the key under which same product\_id got  
aggregated. In other word if I remove \_id, how Elasticsearch will know  
under which Key aggregate the array items (product\_info\_id).

I suppose this is a basic issue but I just can't make it work...

Many thanks in advance for your help.  
Ez

On Tuesday, 9 September 2014 13:01:46 UTC+1, vineeth mohan wrote:

> Hello ,
> 
> Is product\_id unique , seems to me its not.  
> In that case why have you made it as \_id.  
> \_id should be unique and in face of dedupe , it would be over written.  
> So remove defenition of \_id should solve the issue.
> 
> Thanks  
> Vineeth
> 
> On Tue, Sep 9, 2014 at 4:09 PM, EzCocos \<[jmde...@gmail.com](mailto:jmde...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > Dear All,  
> > I am trying to upload via a river to Elasticsearch some MySQL data which  
> > look like this:  
> > product\_id product\_info\_id  
> > '1' 1  
> > '1' 2  
> > '2' 3  
> > '2' 4
> > 
> > I am looking to have in Elasticsearch for this example 2 documents with  
> > \_id '1' and '2' containing each an array of product\_info\_id.
> > 
> > I have been struggling with this for days, I get either 4 documents or 2  
> > documents stored and 2 deleted. The mapping I used so far is this:  
> > {  
> > "product\_merchant" : {  
> > "\_source" : { "enabled" : false },  
> > "\_id" : { "path" : "product\_id" },  
> > "properties" : {  
> > "product\_infos" : {  
> > "properties" : {  
> > "product\_info\_id" : { "type" : "integer", "store" : "yes" }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > Could anyone help me to correct my mapping and/or provide some array  
> > examples?
> > 
> > Many thanks in advance,  
> > jm
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 9, 2014, 1:44pm UTC](https://discuss.elastic.co/t/simple-array-example/19677/4 "2014-09-09T13:44:23Z")

</div>

Hello ,

In that case you should make product\_id as \_type rather than \_id.

Thanks  
Vineeth

On Tue, Sep 9, 2014 at 6:38 PM, EzCocos [jmdepinay@gmail.com](mailto:jmdepinay@gmail.com) wrote:

> Many thanks Vineeth for your help.
> 
> product\_id is indeed unique. If I remove \_id I get 4 documents rather than  
> 2 documents containing each an array of related product\_info\_id.
> 
> I guess I want \_id to be the key under which same product\_id got  
> aggregated. In other word if I remove \_id, how Elasticsearch will know  
> under which Key aggregate the array items (product\_info\_id).
> 
> I suppose this is a basic issue but I just can't make it work...
> 
> Many thanks in advance for your help.  
> Ez
> 
> On Tuesday, 9 September 2014 13:01:46 UTC+1, vineeth mohan wrote:
> 
> > Hello ,
> > 
> > Is product\_id unique , seems to me its not.  
> > In that case why have you made it as \_id.  
> > \_id should be unique and in face of dedupe , it would be over written.  
> > So remove defenition of \_id should solve the issue.
> > 
> > Thanks  
> > Vineeth
> > 
> > On Tue, Sep 9, 2014 at 4:09 PM, EzCocos [jmde...@gmail.com](mailto:jmde...@gmail.com) wrote:
> > 
> > > Dear All,  
> > > I am trying to upload via a river to Elasticsearch some MySQL data which  
> > > look like this:  
> > > product\_id product\_info\_id  
> > > '1' 1  
> > > '1' 2  
> > > '2' 3  
> > > '2' 4
> > > 
> > > I am looking to have in Elasticsearch for this example 2 documents with  
> > > \_id '1' and '2' containing each an array of product\_info\_id.
> > > 
> > > I have been struggling with this for days, I get either 4 documents or 2  
> > > documents stored and 2 deleted. The mapping I used so far is this:  
> > > {  
> > > "product\_merchant" : {  
> > > "\_source" : { "enabled" : false },  
> > > "\_id" : { "path" : "product\_id" },  
> > > "properties" : {  
> > > "product\_infos" : {  
> > > "properties" : {  
> > > "product\_info\_id" : { "type" : "integer", "store" : "yes" }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Could anyone help me to correct my mapping and/or provide some array  
> > > examples?
> > > 
> > > Many thanks in advance,  
> > > jm
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5neQNWKgbV%3DGFndEOwc5CoWs6CWf\_kUJA2zZx580p3iGQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5neQNWKgbV%3DGFndEOwc5CoWs6CWf_kUJA2zZx580p3iGQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![EzCocos](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EzCocos](https://discuss.elastic.co/u/EzCocos)\
**Post date:** [September 9, 2014, 2:04pm UTC](https://discuss.elastic.co/t/simple-array-example/19677/5 "2014-09-09T14:04:43Z")

</div>

Sorry! but I don't understand. I tried to replace \_id by \_type and I get 4  
documents.

Would you be able to give me the related short mapping that would work? For  
instance for the data:

product\_id product\_info\_id  
'1' 1  
'1' 2  
'2' 3  
'2' 4

I would like to create via a river (select \* from product\_table) and get 2  
Elasticsearch documents. The one with id=1 containing an array of  
product\_info\_id containing (1,2) and the one with id=2 the  
product\_info\_id=(3,4).

Many thanks in advance.  
Ez

On Tuesday, 9 September 2014 14:44:32 UTC+1, vineeth mohan wrote:

> Hello ,
> 
> In that case you should make product\_id as \_type rather than \_id.
> 
> Thanks  
> Vineeth
> 
> On Tue, Sep 9, 2014 at 6:38 PM, EzCocos \<[jmde...@gmail.com](mailto:jmde...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > Many thanks Vineeth for your help.
> > 
> > product\_id is indeed unique. If I remove \_id I get 4 documents rather  
> > than 2 documents containing each an array of related product\_info\_id.
> > 
> > I guess I want \_id to be the key under which same product\_id got  
> > aggregated. In other word if I remove \_id, how Elasticsearch will know  
> > under which Key aggregate the array items (product\_info\_id).
> > 
> > I suppose this is a basic issue but I just can't make it work...
> > 
> > Many thanks in advance for your help.  
> > Ez
> > 
> > On Tuesday, 9 September 2014 13:01:46 UTC+1, vineeth mohan wrote:
> > 
> > > Hello ,
> > > 
> > > Is product\_id unique , seems to me its not.  
> > > In that case why have you made it as \_id.  
> > > \_id should be unique and in face of dedupe , it would be over written.  
> > > So remove defenition of \_id should solve the issue.
> > > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Tue, Sep 9, 2014 at 4:09 PM, EzCocos [jmde...@gmail.com](mailto:jmde...@gmail.com) wrote:
> > > 
> > > > Dear All,  
> > > > I am trying to upload via a river to Elasticsearch some MySQL data  
> > > > which look like this:  
> > > > product\_id product\_info\_id  
> > > > '1' 1  
> > > > '1' 2  
> > > > '2' 3  
> > > > '2' 4
> > > > 
> > > > I am looking to have in Elasticsearch for this example 2 documents with  
> > > > \_id '1' and '2' containing each an array of product\_info\_id.
> > > > 
> > > > I have been struggling with this for days, I get either 4 documents or  
> > > > 2 documents stored and 2 deleted. The mapping I used so far is this:  
> > > > {  
> > > > "product\_merchant" : {  
> > > > "\_source" : { "enabled" : false },  
> > > > "\_id" : { "path" : "product\_id" },  
> > > > "properties" : {  
> > > > "product\_infos" : {  
> > > > "properties" : {  
> > > > "product\_info\_id" : { "type" : "integer", "store" : "yes" }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Could anyone help me to correct my mapping and/or provide some array  
> > > > examples?
> > > > 
> > > > Many thanks in advance,  
> > > > jm
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/05aa08d0-8a3e-440e-8131-cb37c70d10df%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ddef0646-cd57-4027-9086-43f83ab40a0f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/669a41da-8719-477e-96c4-27e1492601a8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/669a41da-8719-477e-96c4-27e1492601a8%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:03am UTC](https://discuss.elastic.co/t/simple-array-example/19677/6 "2017-07-06T01:03:42Z")

</div>


