Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE ES 7.4 Script score #48081

Closed
UW-SG opened this issue Oct 15, 2019 · 2 comments · Fixed by #48425
Closed

NPE ES 7.4 Script score #48081

UW-SG opened this issue Oct 15, 2019 · 2 comments · Fixed by #48425
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@UW-SG
Copy link

UW-SG commented Oct 15, 2019

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;"
      }
    }
  }
}
@polyfractal polyfractal added :Search/Search Search-related issues that do not fall into other categories >bug labels Oct 15, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@jimczi
Copy link
Contributor

jimczi commented Oct 15, 2019

Looks like we're trying to unbox a null value into a float when the query is rewritten. It should work if you add a "minScore": 0" in the script_sore like this:

{
  "query": {
    "script_score": {
      "min_score": 0,
      ....

... but this is definitely a bug. @mayya-sharipova can you take a look ?

mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this issue Oct 23, 2019
Previously there was a bug when an query inside script_score query
was rewritten. If min_score was not set and was equal to null,
we were converting it to float value which resulted to NPE.
This commit corrects this.

Closes elastic#48081
mayya-sharipova added a commit that referenced this issue Oct 23, 2019
Previously there was a bug when an query inside script_score query
was rewritten. If min_score was not set and was equal to null,
we were converting it to float value which resulted to NPE.
This commit corrects this.

Closes #48081
mayya-sharipova added a commit that referenced this issue Oct 23, 2019
Previously there was a bug when an query inside script_score query
was rewritten. If min_score was not set and was equal to null,
we were converting it to float value which resulted to NPE.
This commit corrects this.

Closes #48081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants