I have an entity XEntity which have a list of children of the same type. Each entity can have a list of his children. They are related to each other via “parent-child relationship”.(https://www.elastic.co/guide/en/elasticsearch/client/net-api/master/parent-child-relationships.html)

https://imgur.com/KmnGOPg

I can insert or update those entities without any problem, but I can’t get together. Who can help me? Thanks in advance.

If you are using parent-child relationship, then you can find child by parent and vice versa

Finding Children by Their Parents

GET /company/employee/_search
{
  "query": {
    "has_parent": {
      "type": "branch", 
      "query": {
        "match": {
          "country": "UK"
        }
      },
      "inner_hits": {}
    }
  }
}

And Finding Parents by Their Children

GET /company/branch/_search
{
  "query": {
    "has_child": {
      "type": "employee",
      "query": {
        "range": {
          "dob": {
            "gte": "1980-01-01"
          }
        }
      },
      "inner_hits": {}
    }
  }
}