# One to many relation

**URL:** <https://discuss.elastic.co/t/one-to-many-relation/352035>\
**Category:** Elasticsearch\
**Created:** [January 29, 2024, 9:39pm UTC](https://discuss.elastic.co/t/one-to-many-relation/352035 "2024-01-29T21:39:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![imane\_ajroudi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imane_ajroudi/32/131207_2.png) [@imane\_ajroudi](https://discuss.elastic.co/u/imane_ajroudi)\
**Post date:** [January 29, 2024, 9:39pm UTC](https://discuss.elastic.co/t/one-to-many-relation/352035/1 "2024-01-29T21:39:55Z")

</div>

Hello guys , please i need help urgennnt ,, ihave this mapping , normaly i should have data ,each item should have multipple detail\_name, detail\_description, type\_name ,, but i have only one each item ,, this is my mapping {  
"mappings": {  
"dynamic": "false",  
"\_source": {  
"enabled": true,  
"includes": [  
"created\_at",  
"updated\_at",  
"date",  
"lang.keyword",  
"source.id",  
"source\_type.keyword",  
"source.name\_fr",  
"source.created\_at",  
"source.updated\_at",  
"source.logo\_url",  
"source.reach",  
"source.reach.id",  
"source.reach.source\_name",  
"source.reach.source\_name.keyword",  
"source.reach.reach\_score.keyword",  
"author",  
"title",  
"content",  
"sentiment",  
"source",  
"source\_type",  
"source\_name",  
"\_\_class\_name",  
"lang",  
"detail",  
"detail.name",  
"detail.description",  
"detail.created\_at",  
"detail.hashed\_link",  
"detail.type\_id",  
"detail\_name",  
"detail\_description",  
"detail\_name.keyword",  
"detail\_description.keyword",  
"type\_name",  
"type\_name.keyword",  
"type.type",  
"type",  
"type\_id",  
"type\_id.keyword"  
]  
},  
"properties": {  
"\_\_class\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"author": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256,  
"index\_options": "freqs"  
}  
},  
"term\_vector": "with\_positions\_offsets",  
"fielddata": true  
},  
"category\_id": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"content": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"index\_options": "freqs",  
"norms": true  
}  
},  
"index\_options": "offsets",  
"term\_vector": "with\_positions\_offsets",  
"fielddata": true,  
"fielddata\_frequency\_filter": {  
"min": 0.01,  
"max": 1,  
"min\_segment\_size": 50  
}  
},  
"created\_at": {  
"type": "date"  
},  
"date": {  
"type": "date"  
},  
"detail": {  
"type": "nested",  
"properties": {  
"created\_at": {  
"type": "date"  
},  
"description": {  
"type": "text"  
},  
"hashed\_link": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"name": {  
"type": "text"  
},  
"type\_id": {  
"type": "long"  
}  
}  
},  
"detail\_description": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"detail\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"hashed\_link": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"id": {  
"type": "long"  
},  
"lang": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"lat": {  
"type": "float"  
},  
"link": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"lon": {  
"type": "float"  
},  
"reach": {  
"properties": {  
"date": {  
"type": "date"  
},  
"id": {  
"type": "long"  
},  
"reach\_score": {  
"type": "double"  
},  
"source\_name": {  
"type": "text"  
}  
}  
},  
"reach\_score": {  
"type": "float"  
},  
"sentiment": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"source": {  
"properties": {  
"created\_at": {  
"type": "date"  
},  
"id": {  
"type": "long"  
},  
"logo\_url": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"name\_ar": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"name\_fr": {  
"type": "text"  
},  
"reach": {  
"properties": {  
"date": {  
"type": "date"  
},  
"id": {  
"type": "long"  
},  
"reach\_score": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"source\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
},  
"sourcetype\_id": {  
"type": "text"  
},  
"updated\_at": {  
"type": "date"  
}  
}  
},  
"source\_id": {  
"type": "long"  
},  
"source\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"source\_type": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"sourcetype": {  
"properties": {  
"name": {  
"type": "text"  
}  
}  
},  
"title": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256,  
"index\_options": "freqs"  
}  
},  
"term\_vector": "with\_positions\_offsets",  
"fielddata": true  
},  
"type\_id": {  
"type": "long",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"type\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"updated\_at": {  
"type": "text"  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [January 30, 2024, 10:31am UTC](https://discuss.elastic.co/t/one-to-many-relation/352035/2 "2024-01-30T10:31:06Z")

</div>

Hi @imane_ajroudi,

Welcome to the community! Am I correct in my understanding that you want to model a relationship where for each document you can have many values for fields such as `detail.description`? Is there a relationship between the `detail.name` and `detail.description` values?

[As covered in the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html) Elasticsearch doesn't have a dedicated array type, and fields support 0 or more values. Depending on how you want to search for multiple values you might want to consider either:

1. Using the default functionality as covered in the link above.
2. Model your data as a [nested type](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html), making sure to note the [limitations of this approach](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html#_limits_on_nested_mappings_and_objects).

Hope that helps!

---

<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:** [February 27, 2024, 10:32am UTC](https://discuss.elastic.co/t/one-to-many-relation/352035/3 "2024-02-27T10:32:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
