# Elastic Search Null pointer exception in two different join types while fetching their parents

**URL:** <https://discuss.elastic.co/t/elastic-search-null-pointer-exception-in-two-different-join-types-while-fetching-their-parents/267922>\
**Category:** Elasticsearch\
**Created:** [March 21, 2021, 11:00pm UTC](https://discuss.elastic.co/t/elastic-search-null-pointer-exception-in-two-different-join-types-while-fetching-their-parents/267922 "2021-03-21T23:00:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Syed\_ali\_abbas\_shah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/syed_ali_abbas_shah/32/30053_2.png) [@Syed\_ali\_abbas\_shah](https://discuss.elastic.co/u/Syed_ali_abbas_shah)\
**Post date:** [March 21, 2021, 11:00pm UTC](https://discuss.elastic.co/t/elastic-search-null-pointer-exception-in-two-different-join-types-while-fetching-their-parents/267922/1 "2021-03-21T23:00:58Z")

</div>

I have very simple mapping in Elastic Search 6.x version, and following is my mapping with two different types bookmarks user can also be bookmarked and post can also be bookmarked,

`{ "properties": { "type": { "type": "join", "relations": { "user": ["user_bookmarks"], "post": ["post_bookmarks"] } } } }`

I am trying to fetch both types of bookmarks on a same time , with their parent as inner\_hits using has\_parent block

```auto
GET /trending/doc/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "type": "user_bookmarks"
                }
              },
              {
                "has_parent": {
                  "parent_type": "user",
                  "inner_hits":{
                    "_source":["id"]
                  },
                  "query": {
                    "match_all": {}
                  }
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must": [
              {
                "term": {
                  "type": "post_bookmarks"
                }
              },
              {
                "has_parent": {
                  "parent_type": "post",
                 
                   "inner_hits":{
                    "_source":["id"]
                  },
                  "query": {
                    "match_all": {}
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

But i get the following error in has\_parent inner\_hits

`{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 4, "skipped" : 0, "failed" : 1, "failures" : [{ "shard" : 3, "index" : "trending", "node" : "hTYvbi70QKGHZvuFYHtnlA", "reason" : { "type" : "null_pointer_exception", "reason" : null } }] }, "hits" : { "total" : 1, "max_score" : 10.267918, "hits" : [] } }`

---

<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:** [April 18, 2021, 11:01pm UTC](https://discuss.elastic.co/t/elastic-search-null-pointer-exception-in-two-different-join-types-while-fetching-their-parents/267922/2 "2021-04-18T23:01:12Z")

</div>

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