# NPE ES 7.4 Script score

**URL:** <https://discuss.elastic.co/t/npe-es-7-4-script-score/203525>\
**Category:** Elasticsearch\
**Created:** [October 14, 2019, 9:24pm UTC](https://discuss.elastic.co/t/npe-es-7-4-script-score/203525 "2019-10-14T21:24:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgTextSearch](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@sgTextSearch](https://discuss.elastic.co/u/sgTextSearch)\
**Post date:** [October 14, 2019, 9:24pm UTC](https://discuss.elastic.co/t/npe-es-7-4-script-score/203525/1 "2019-10-14T21:24:23Z")

</div>

NPE when using script scores query across multiple indices.

When a range clause is written on a field that exists in just one index, the other indices throw NPE.

org.elasticsearch.transport.RemoteTransportException: [MSEAIT1034064][127.0.0.1:9300][indices:data/read/search[phase/dfs]]

Caused by: java.lang.NullPointerException

at org.elasticsearch.index.query.functionscore.ScriptScoreQueryBuilder.doRewrite(ScriptScoreQueryBuilder.java:176) ~[elasticsearch-7.4.0.jar:7.4.0]  
at org.elasticsearch.index.query.AbstractQueryBuilder.rewrite(AbstractQueryBuilder.java:265) ~[elasticsearch-7.4.0.jar:7.4.0]  
at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:962) ~[elasticsearch-7.4.0.jar:7.4.0]  
at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:82) ~[elasticsearch-7.4.0.jar:7.4.0]  
at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:68) ~[elasticsearch-7.4.0.jar:7.4.0]

If the script\_score clause is removed, the query runs fine.

```
 POST ind1, ind2, ind3/_search?search_type=dfs_query_then_fetch
{
  "query": {
    "script_score": {
      "query": {
        "bool": {
          "should": [
            {
              "multi_match": {
                "query": "HR policies",
                "fields": [
                  "title",
                  "body"
                ]
              }
            },
            {
              "range": {
                "ind1+valid_to": {
                  "from": "now",
                  "to": null,
                  "include_lower": true,
                  "include_upper": true,
                  "boost": 1
                }
              }
            }
          ]
        }
      },
      "script": {
        "source": "return 1;"
      }
    }
  }
}
```

---

<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:** [November 11, 2019, 9:24pm UTC](https://discuss.elastic.co/t/npe-es-7-4-script-score/203525/2 "2019-11-11T21:24:32Z")

</div>

Closed on November 11, 2019, 9:24pm UTC

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