# Has\_parent query returns no hits in elasticsearch 6.5.4

**URL:** <https://discuss.elastic.co/t/has-parent-query-returns-no-hits-in-elasticsearch-6-5-4/187950>\
**Category:** Elasticsearch\
**Created:** [June 28, 2019, 12:13am UTC](https://discuss.elastic.co/t/has-parent-query-returns-no-hits-in-elasticsearch-6-5-4/187950 "2019-06-28T00:13:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luise](https://avatars.discourse-cdn.com/v4/letter/l/f1d935/32.png) [@luise](https://discuss.elastic.co/u/luise)\
**Post date:** [June 28, 2019, 12:13am UTC](https://discuss.elastic.co/t/has-parent-query-returns-no-hits-in-elasticsearch-6-5-4/187950/1 "2019-06-28T00:13:28Z")

</div>

I'm currently trying to find all children of parents that match certain query using the following has\_parent query:

```
GET my_index*/_search
{
  "query": {
    "has_parent": {
      "parent_type": "threat",
      "query": {
        "term": {
          "type.keyword": {
            "value": "ip"
          }
        }
      }
    }
  }
}

```

But it returns no hits, even with a match\_all query.

The mapping of the index is as follows:

```
"my_index" : {
    "mappings" : {
      "doc" : {
        "properties" : {
          "@timestamp" : {
            "type" : "date"
          },
          "@version" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "asn_info" : {
            "properties" : {
              "as_org" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "asn" : {
                "type" : "long"
              }
            }
          },
          "campaign" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "category" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "category_description" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "confidence" : {
            "type" : "float"
          },
          "criticity" : {
            "type" : "float"
          },
          "detection_date" : {
            "type" : "float"
          },
          "feed" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "feeds" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "geo" : {
            "properties" : {
              "city_name" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "country_code2" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "country_code3" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "country_name" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "latitude" : {
                "type" : "float"
              },
              "longitude" : {
                "type" : "float"
              }
            }
          },
          "hierarchy" : {
            "type" : "join",
            "eager_global_ordinals" : true,
            "relations" : {
              "threat" : "date"
            }
          },
          "host" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "ip" : {
            "type" : "long"
          },
          "ip_address" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "name" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "port" : {
            "type" : "long"
          },
          "subcategory" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "tags" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "timestamp" : {
            "type" : "date"
          },
          "type" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    }
  }

```

As you can see, the hierarchy field is a join field, with "threat" defined as parent of "date". I don't see any problem with this. Does anyone know what could be happening?

Thanks!  
Luis

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 1, 2019, 9:54am UTC](https://discuss.elastic.co/t/has-parent-query-returns-no-hits-in-elasticsearch-6-5-4/187950/4 "2019-07-01T09:54:51Z")

</div>

Hey,

providing a minimal example, that includes index creation, document indexing and only the absolutely minimal mapping required to reproduce would help others to take a closer look here.

Also the Elasticsearch version you are using is always super helpful!

Thanks a lot!

--Alex

---

<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 29, 2019, 9:54am UTC](https://discuss.elastic.co/t/has-parent-query-returns-no-hits-in-elasticsearch-6-5-4/187950/5 "2019-07-29T09:54:56Z")

</div>

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