Failed to create query: Score function should not be null

We are trying to move from ES 6.8 to ES 7.17. On an ES query we are getting the following error (the same query was working fine in ES 6.8):

When I try Kibana also, I get the same error:

"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: Score function should not be null",
"index_uuid": "wJbAGA__Sgil2pVHvgD6IA",
"index": "code_sourcenodedupefilecontractv3_1421_shared"
}

=========================

Any suggestions will be very helpful.

Full query and exception below -

  1. Query:
    =========
GET code_sourcenodedupefilecontractv3_1421_shared/_search
{
  "query": {
  "bool": {
    "must": {
      "bool": {
        "should": [
          {
            "codesearch_score_query": {
              "query_id": "dd212257-556a-4d47-8143-0972c10718f4",
              "query": {
                "term": {
                  "content": "class"
                }
              }
            }
          },
          {
            "function_score": {
              "boost": 10000000,
              "query": {
                "term": {
                  "fileName": {
                    "value": "class",
                    "_name": "fileName_class"
                  }
                }
              }
            }
          }
        ]
      }
    },
    "filter": {
      "bool": {
        "must": [
          {
            "bool": {
              "must": [
                {
                  "bool": {
                    "must": [
                      {
                        "bool": {
                          "should": [
                            {
                              "bool": {
                                "should": [
                                  {
                                    "bool": {
                                      "must": [
                                        {
                                          "terms": {
                                            "vcType": [
                                              "git"
                                            ]
                                          }
                                        }
                                      ],
                                      "must_not": [
                                        {
                                          "terms": {
                                            "repositoryId": [
                                              "d25b2a5f-76fc-4fb9-a09f-4a19124213e4"
                                            ]
                                          }
                                        }
                                      ]
                                    }
                                  },
                                  {
                                    "terms": {
                                      "vcType": [
                                        "tfvc"
                                      ]
                                    }
                                  }
                                ]
                              }
                            },
                            {
                              "terms": {
                                "vcType": [
                                  "custom"
                                ]
                              }
                            }
                          ]
                        }
                      },
                      {
                        "term": {
                          "isDefaultBranch": "true"
                        }
                      }
                    ]
                  }
                },
                {
                  "bool": {
                    "filter": {
                      "terms": {
                        "projectId": [
                          "eac210c4-399e-419a-9909-691014e475c1"
                        ],
                        "_name": "projectId_eac210c4-399e-419a-9909-691014e475c1"
                      }
                    }
                  }
                }
              ]
            }
          },
          {
            "term": {
              "collectionId": "fd4f94ce-d825-408c-9a68-0ce5ecd544da"
            }
          }
        ]
      }
    }
  }
}
}

==============================================================
==============================================================

2. Error Message:

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to create query: Score function should not be null",
        "index_uuid": "wJbAGA__Sgil2pVHvgD6IA",
        "index": "code_sourcenodedupefilecontractv3_1421_shared"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "code_sourcenodedupefilecontractv3_1421_shared",
        "node": "eDb-Xyx_RJOgcPLmErF8Ww",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to create query: Score function should not be null",
          "index_uuid": "wJbAGA__Sgil2pVHvgD6IA",
          "index": "code_sourcenodedupefilecontractv3_1421_shared",
          "caused_by": {
            "type": "illegal_argument_exception",
            "reason": "Score function should not be null"
          }
        }
      }
    ]
  },
  "status": 400
}

Wanted to provide some additional info. We are using custom analyzer. Here is the stackTrace for the issue.

All shards failed for phase: [query]
org.elasticsearch.index.query.QueryShardException: failed to create query: Score function should not be null
	at org.elasticsearch.index.query.SearchExecutionContext.toQuery(SearchExecutionContext.java:557) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.SearchExecutionContext.toQuery(SearchExecutionContext.java:540) ~[elasticsearch-7.17.5.jar:7.17.5] 
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:1171) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:982) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:618) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.search.SearchService.lambda$executeQueryPhase$2(SearchService.java:483) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47) [elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) [elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33) [elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:777) [elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) [elasticsearch-7.17.5.jar:7.17.5]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_212]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_212]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.IllegalArgumentException: Score function should not be null
	at org.elasticsearch.common.lucene.search.function.FunctionScoreQuery.<init>(FunctionScoreQuery.java:173) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.common.lucene.search.function.FunctionScoreQuery.<init>(FunctionScoreQuery.java:152) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.common.lucene.search.function.FunctionScoreQuery.<init>(FunctionScoreQuery.java:140) ~[elasticsearch-7.17.5.jar:7.17.5]
	at com.custom.search.relevance.CodeSearchScoreQuery.<init>(CodeSearchScoreQuery.java:33) ~[?:?]
	at com.custom.search.relevance.CodeSearchScoreQueryBuilder.doToQuery(CodeSearchScoreQueryBuilder.java:111) ~[?:?]
	at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:90) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:348) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:330) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:90) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:348) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:328) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:90) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.SearchExecutionContext.lambda$toQuery$3(SearchExecutionContext.java:541) ~[elasticsearch-7.17.5.jar:7.17.5]
	at org.elasticsearch.index.query.SearchExecutionContext.toQuery(SearchExecutionContext.java:553) ~[elasticsearch-7.17.5.jar:7.17.5]
	... 14 more

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