# Modeling Objects That Have Many Properties

**URL:** <https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/23629>\
**Category:** Elasticsearch\
**Created:** [May 15, 2015, 12:52pm UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/23629 "2015-05-15T12:52:49Z")\
**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, 12:52pm UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/23629/1 "2015-05-15T12:52:49Z")

</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

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/6fdbfe26-4032-4664-91ce-582a0d832bf4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fdbfe26-4032-4664-91ce-582a0d832bf4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 9:42pm UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/23629/2 "2015-05-15T21:42:45Z")

</div>

You probably want to use parent/child instead, that way you don't have to  
update the entire document each time, just the child(ren).

PS - We're moving to [https://discuss.elastic.co/](https://discuss.elastic.co/), please join us there for  
any future discussions!

On 15 May 2015 at 22:52, Peter Hodgman [peter.hodgman@gmail.com](mailto:peter.hodgman@gmail.com) wrote:

> 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
> 
> ## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)
> 
> 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/6fdbfe26-4032-4664-91ce-582a0d832bf4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fdbfe26-4032-4664-91ce-582a0d832bf4%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/6fdbfe26-4032-4664-91ce-582a0d832bf4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6fdbfe26-4032-4664-91ce-582a0d832bf4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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/CAEYi1X\_sGhLc%2BxtdbmzAUWDAPOByNBZHSSy%3DiFUS4fne0Vc\_%2Bg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X_sGhLc%2BxtdbmzAUWDAPOByNBZHSSy%3DiFUS4fne0Vc_%2Bg%40mail.gmail.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, 12:13am UTC](https://discuss.elastic.co/t/modeling-objects-that-have-many-properties/23629/3 "2017-07-06T00:13:46Z")

</div>


