# Setting type 'array' as object type

**URL:** <https://discuss.elastic.co/t/setting-type-array-as-object-type/14245>\
**Category:** Elasticsearch\
**Created:** [November 4, 2013, 5:15pm UTC](https://discuss.elastic.co/t/setting-type-array-as-object-type/14245 "2013-11-04T17:15:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oreno](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@oreno](https://discuss.elastic.co/u/oreno)\
**Post date:** [November 4, 2013, 5:15pm UTC](https://discuss.elastic.co/t/setting-type-array-as-object-type/14245/1 "2013-11-04T17:15:46Z")

</div>

Hi,  
I'd like to be able to set index mapping for accepting documents such as the one below.  
not sure what type I should declare the 'products' field to be.  
setting 'type':'array' doesn't validate(fails on mapping) and setting it as 'type':'object ' doesn't accept the this document structure (fails on indexing):

MapperParsingException[object mapping [segments] trying to serialize a value with no field associated with it, current value [123]]

Any idea what's the right configuration I should use here?

\*I'm able to insert the document without mapping but I've to have it with mapping because the event type needs to be set as nested..

mapping:  
'{  
"user": {  
"\_ttl": {  
"enabled": true  
},  
"properties": {  
"events": {  
"type": "nested",  
"properties": {  
"event\_time": {  
"type": "Date"  
},  
"products": {  
"type": "array" , //(or 'object)  
"index": "not\_analyzed"  
}  
}  
}  
}  
}  
}'

document:  
{  
"id": "1",  
"events": [{  
"date": "2013-11-04",  
"products": ["123","234","AA345"]  
},  
{  
"date": "2013-11-04",  
"products": ["123","234","BB345"]  
}]  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 4, 2013, 5:21pm UTC](https://discuss.elastic.co/t/setting-type-array-as-object-type/14245/2 "2013-11-04T17:21:42Z")

</div>

Could you gist a full curl recreation?

Note that you are using date field name instead of event\_type but this is another story!

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 nov. 2013 à 18:15, oreno [oreno@exelate.com](mailto:oreno@exelate.com) a écrit :

> Hi,  
> I'd like to be able to set index mapping for accepting documents such as the  
> one below.  
> not sure what type I should declare the 'products' field to be.  
> setting 'type':'array' doesn't validate(fails on mapping) and setting it as  
> 'type':'object ' doesn't accept the this document structure (fails on  
> indexing):
> 
> MapperParsingException[object mapping [segments] trying to serialize a value  
> with no field associated with it, current value [123]]
> 
> Any idea what's the right configuration I should use here?
> 
> \*I'm able to insert the document without mapping but I've to have it with  
> mapping because the event type needs to be set as nested..
> 
> mapping:  
> '{  
> "user": {  
> "\_ttl": {  
> "enabled": true  
> },  
> "properties": {  
> "events": {  
> "type": "nested",  
> "properties": {  
> "event\_time": {  
> "type": "Date"  
> },  
> "products": {  
> "type": "array" , //(or 'object)  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> document:  
> {  
> "id": "1",  
> "events": [{  
> "date": "2013-11-04",  
> "products": ["123","234","AA345"]  
> },  
> {  
> "date": "2013-11-04",  
> "products": ["123","234","BB345"]  
> }]  
> }
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/setting-type-array-as-object-type-tp4043714.html](http://elasticsearch-users.115913.n3.nabble.com/setting-type-array-as-object-type-tp4043714.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:09am UTC](https://discuss.elastic.co/t/setting-type-array-as-object-type/14245/3 "2017-07-06T02:09:00Z")

</div>


