# "Cannot invoke "java.util.List.get(int)" because "nestedParsedSource" is null" when using nested properties + has\_parent + inner\_hits

**URL:** <https://discuss.elastic.co/t/cannot-invoke-java-util-list-get-int-because-nestedparsedsource-is-null-when-using-nested-properties-has-parent-inner-hits/279967>\
**Category:** Elasticsearch\
**Created:** [July 29, 2021, 10:38am UTC](https://discuss.elastic.co/t/cannot-invoke-java-util-list-get-int-because-nestedparsedsource-is-null-when-using-nested-properties-has-parent-inner-hits/279967 "2021-07-29T10:38:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavelfry](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@pavelfry](https://discuss.elastic.co/u/pavelfry)\
**Post date:** [July 29, 2021, 10:38am UTC](https://discuss.elastic.co/t/cannot-invoke-java-util-list-get-int-because-nestedparsedsource-is-null-when-using-nested-properties-has-parent-inner-hits/279967/1 "2021-07-29T10:38:19Z")

</div>

Hello everyone,

I've been banging my head against this for a while and it seems I've reached a dead end. I've tried to simplify the code as much as possible.

Problem:  
I'm using the child/parent relationships and nested type property (on the parent) in my mapping also with the explicit _type_ field as in documentation.

My query is to fetch documents of certain type (event in the example), which have a parent and use _inner\_hits_ on the _has\_parent_ query to fetch also the information about the parent using _\_source_.

This all works until the **parent** document has at least 1 **nested** field indexed, in that case the query fails with the exception:

"Cannot invoke "java.util.List.get(int)" because "nestedParsedSource" is null"

**My index & mapping:**

```auto
DELETE /test
PUT /test
{
    "mappings": {
        "dynamic": false,
        "_meta": { "version": "0073_00" },
        "properties": {
            "id": { "type": "keyword" },
            "role": {
                "type": "join",
                "eager_global_ordinals": true,
                "relations": {
                    "user": ["event"]
                }
            },
            "type": { "type": "keyword" },
            "username": { "type": "text" },
            "title": { "type": "text" },
            "fields": {
                "dynamic": false,
                "type": "nested",
                "properties": {
                    "value": { "type": "keyword" },
                    "key": { "type": "keyword" }
                }
            }
        }
    }
}

```

**Indexing a User and one Event, notice User has nested data** :

```auto
POST /test/_doc/u-1?refresh
{
    "id": "u-1",
    "username": "User1",
    "role": "user",
    "type": "user",
    "fields": [
        {"key": "GMC", "value": "111111"}
    ]
}
POST /test/_doc/e-1?routing=u-1&refresh
{
    "id": "e-1",
    "title": "Event 1",
    "type": "event",
    "role": {
        "name": "event",
        "parent": "u-1"
    }
}

```

**Query I use, notice '\_source:true' which fails with the above exception.**

```auto
GET /test/_search
{
    "_source": false,
    "fields": ["title"],
    "query": {
        "bool": {
            "must": [
                { "term": { "type": "event" } },
                {
                    "has_parent": {
                        "query": { "match_all": {} },
                        "inner_hits": { "_source":true },
                        "parent_type": "user"
                    }
                }
            ]
        }
    }
}

```

**If I change the '\_source:false' on the 'inner\_hits' in the query, it returns results but the inner\_hits includes the nested property in the 'inner\_hits' which I have no idea why.**

```auto
"inner_hits": {
    "user": {
        "hits": {
            "total": {
                "value": 2,
                "relation": "eq"
            },
            "max_score": 1,
            "hits": [
                {
                    "_index": "test",
                    "_type": "_doc",
                    "_id": "e-1",
                    "_nested": {
                        "field": "fields",
                        "offset": 0
                    },
                    "_score": 1
                },
                {
                    "_index": "test",
                    "_type": "_doc",
                    "_id": "u-1",
                    "_score": 1
                }
            ]
        }
    }
}

```

**Finally if I change the query to fetch a specific parent ID, the query returns valid result**

```auto
GET /test/_search
{
    "_source": false,
    "fields": ["title"],
    "query": {
        "bool": {
            "must": [
                { "term": { "type": "event" } },
                {
                    "has_parent": {
                        "query": { "term": {"id": "u-1"} },
                        "inner_hits": { "_source": true },
                        "parent_type": "user"
                    }
                }
            ]
        }
    }
}

```

```auto
...
"inner_hits": {
    "user": {
        "hits": {
            "total": {
                "value": 1,
                "relation": "eq"
            },
            "max_score": 0.6931471,
            "hits": [
                {
                    "_index": "test",
                    "_type": "_doc",
                    "_id": "u-1",
                    "_score": 0.6931471,
                    "_source": {
                        "id": "u-1",
                        "username": "User1",
                        "role": "user",
                        "type": "user",
                        "fields": [
                            {
                                "key": "GMC",
                                "value": "111111"
                            }
                        ]
                    }
                }
            ]
        }
    }
}

```

---

<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:** [August 26, 2021, 10:38am UTC](https://discuss.elastic.co/t/cannot-invoke-java-util-list-get-int-because-nestedparsedsource-is-null-when-using-nested-properties-has-parent-inner-hits/279967/2 "2021-08-26T10:38:55Z")

</div>

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