# Modeling Objects That Have Many Properties

**URL:** <https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/750>\
**Category:** Elasticsearch\
**Created:** [May 15, 2015, 1:01pm UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/750 "2015-05-15T13:01:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pete](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete/32/44841_2.png) [@Pete](https://discuss.elastic.co/u/Pete)\
**Post date:** [May 15, 2015, 1:01pm UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/750/1 "2015-05-15T13:01:19Z")

</div>

Hello,

I have a situation where I want to understand the best way to model this data in ES. I have the following data

Object -\> Has Many -\> Properties

where a

Property -\> is a -\> Name (String), and a Value( one of -\> Boolean, Integer, Double, String, Long)

and the Object is the container of the properties via the "the-properties" field below. It also has a simple name field "the-name" as a general object identifier.

So essentially I have an object that has many properties where each property can have a name, and a value but the value can be one of many types as noted above. So this is a bit dynamic in nature as it relates to the properties value "type".

One way to establish a mapping is as follows, but it seems a bit hacky. Is there a better way?

curl -XPUT '[http://localhost:9200/bo-objects/\_mapping/bo](http://localhost:9200/bo-objects/_mapping/bo)' -d '{  
"bo": {  
"properties": {  
"the-name" : {  
"type" : "string",  
"store" : true  
},  
"the-properties": {  
"type" : "nested",  
"properties" : {  
"name" : {  
"type" : "string",  
"store" : true  
},  
"value" : {  
"type" : "object",  
"properties" : {  
"as\_double" : { "type": "double", "store": true} ,  
"as\_int" : { "type": "integer", "store": true} ,  
"as\_string" : { "type": "string", "store": true} ,  
"as\_bool" : { "type": "boolean", "store": true}  
}  
}  
}  
}  
}  
}  
}'

which results in an ES data structure like this..

"\_source": {  
"name": "My Object",  
"properties": [  
{  
"name": "foo",  
"value": {  
"as\_double": 23.56  
}  
}  
,  
{  
"name": "bar",  
"value": {  
"as\_bool": false  
}  
}  
,  
{  
"name": "bla",  
"value": {  
"as\_double": 22.56  
}  
}  
,  
{  
"name": "junk",  
"value": {  
"as\_double": 8.56  
}  
}  
,  
{  
"name": "fee",  
"value": {  
"as\_string": "D6677"  
}  
}  
]  
}  
}

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 15, 2015, 10:13pm UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/750/2 "2015-05-15T22:13:12Z")

</div>

You probably want to leverage parent/child so that an update doesn't require the entire document to be reindexed.

---

<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, 12:13am UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/750/3 "2017-07-06T00:13:45Z")

</div>


