Different parent's type

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 !

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