# Different parent's type

**URL:** <https://discuss.elastic.co/t/different-parents-type/143892>\
**Category:** Elasticsearch\
**Created:** [August 10, 2018, 3:28pm UTC](https://discuss.elastic.co/t/different-parents-type/143892 "2018-08-10T15:28:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ekaterina\_Nekrasova](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ekaterina_nekrasova/32/46505_2.png) [@Ekaterina\_Nekrasova](https://discuss.elastic.co/u/Ekaterina_Nekrasova)\
**Post date:** [August 10, 2018, 3:28pm UTC](https://discuss.elastic.co/t/different-parents-type/143892/1 "2018-08-10T15:28:05Z")

</div>

Hello !

I use different parent's type for the same type:  
my mapping  
\> "claims" : {

> ```
> "mappings" : {
> "alert" : {
> "_parent" : {
> "type" : "claim"
> },
> "_routing" : {
> "required" : true
> },
> "properties" : {
> "alertDate" : {
> "type" : "date",
> "store" : true,
> "format" : "date_hour_minute_second||date_hour_minute_second_fraction||date"
> },
> "alertId" : {
> "type" : "keyword",
> "store" : true
> }
> }
> },
> "claim" : {
> "properties" : {
> "claimDate" : {"type" : "date",
> "store" : true,
> "ignore_malformed" : true,
> "format" : "date_hour_minute_second||date_hour_minute_second_fraction||date"
> },
> "claimPerson" : {
> "type" : "nested",
> "include_in_parent" : true,
> "properties" : {
> "personId" : {
> "type" : "keyword",
> "store" : true
> },
> "roleEnumIdentifier" : {
> "type" : "keyword",
> "store" : true
> },
> "roleEnumValueId" : {
> "type" : "keyword",
> "store" : true
> }
> }
> }
> }
> }
> },
> "persons" : {
> "mappings" : {
> "alert" : {
> "_parent" : {
> "type" : "person"
> },
> "_routing" : {
> "required" : true
> },
> "properties" : {
> "alertDate" : {
> "type" : "date",
> "store" : true,
> "format" : "date_hour_minute_second||date_hour_minute_second_fraction||date"
> },
> "alertId" : {
> "type" : "keyword",
> "store" : true
> }
> },
> "person" : {
> "properties" : {
> "dateOfBirth" : {
> "type" : "date",
> "store" : true,
> "format" : "date_hour_minute_second||date_hour_minute_second_fraction||date"
> },
> "id" : {
> "type" : "keyword",
> "store" : true
> },
> "name" : {
> "type" : "keyword",
> "store" : true
> }
> }
> }
> }
> }
> 
> ```

i want find all alerts for "person" with the name NAME and all alerts for "claim" with the personId 33 (this is person's ID with the name NAME)  
How can i do it ?  
i use the query

> ```
> {
> "from": 0,
> "size": 10,
> "sort": [
> {
> "alertDate": {
> "order": "desc"
> }
> }
> ],
> "_source": {
> "excludes": [
> "*"
> ]
> },
> "query": {
> "bool": {
> "should": [
> {
> "has_parent": {
> "type": "claim",
> "query": {
> "bool": {
> "must": [
> {
> "nested": {
> "path": "claimPerson",
> "query": {
> "bool": {
> "must": [
> {
> "term": {
> "claimPerson.personId": "33"
> }
> }
> ]
> }
> }
> }
> }
> ]
> }
> }
> }
> },
> {
> "has_parent": {
> "type": "person",
> "query": {
> "bool": {
> "must": [
> {
> "match": {
> "name": {
> "query": "Noah Cunningham",
> "minimum_should_match": "80%",
> "operator": "and"
> }
> }
> }
> ]
> }
> }
> }
> }
> ],
> "minimum_should_match": 1
> }
> }
> }
> 
> ```

thank you !

---

<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:** [September 7, 2018, 3:28pm UTC](https://discuss.elastic.co/t/different-parents-type/143892/2 "2018-09-07T15:28:11Z")

</div>

Closed on September 7, 2018, 3:28pm UTC

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