Script_score query does not support [query]

**Hey everyone,

i'm trying to apply a custom score using script score but i'm facing this issue...i would really appreciate your help

Here's the query i'm using for that.

my query was based on the documentation of Elastic about script_score which includes a query under script_score. Heer is the link to Elastic documentation Script_score query documentation **

{
       "from":0,
       "size":6,
       "query":{
          "bool":{
             "must":{
                "function_score":{
                   "score_mode":"sum",
                   "boost_mode":"replace",
                   "functions":[
                      {
                         "weight":0
                      },
                      {
                         "script_score":{
                            "query":{
                               "bool":{
                                  "filter":{
                                     "term":{
                                        "title":"jordan"
                                     }
                                  }
                               }
                            },
                            "script":{
                               "source":"params.termFreq * Math.log10((params.doCount - (params.allDocFreq  * params.numDocs\/params.maxDocs) + 1) \/ (params.allDocFreq * params.numDocs\/params.maxDocs)) \/ Math.log10(1 + params.doCount) * 1000 \/5",
                               "params":{
                                  "termFreq":1278,
                                  "titleDocFreq":1274,
                                  "allDocFreq":3630,
                                  "doCount":3909828,
                                  "numDocs":4492778,
                                  "maxDocs":4497180
                               }
                            }
                         }
                      },
                      {
                         "script_score":{
                            "query":{
                               "bool":{
                                  "filter":{
                                     "term":{
                                        "title":"faithful"
                                     }
                                  }
                               }
                            },
                            "script":{
                               "source":"params.termFreq * Math.log10((params.doCount - (params.allDocFreq  * params.numDocs\/params.maxDocs) + 1) \/ (params.allDocFreq * params.numDocs\/params.maxDocs)) \/ Math.log10(1 + params.doCount) * 1000 \/5",
                               "params":{
                                  "termFreq":61,
                                  "titleDocFreq":61,
                                  "allDocFreq":391,
                                  "doCount":3909828,
                                  "numDocs":4492778,
                                  "maxDocs":4497180
                               }
                            }
                         }
                      },
                      {
                         "script_score":{
                            "query":{
                               "bool":{
                                  "filter":{
                                     "term":{
                                        "title":"return"
                                     }
                                  }
                               }
                            },
                            "script":{
                               "source":"params.termFreq * Math.log10((params.doCount - (params.allDocFreq  * params.numDocs\/params.maxDocs) + 1) \/ (params.allDocFreq * params.numDocs\/params.maxDocs)) \/ Math.log10(1 + params.doCount) * 1000 \/5",
                               "params":{
                                  "termFreq":1857,
                                  "titleDocFreq":1856,
                                  "allDocFreq":5334,
                                  "doCount":3909828,
                                  "numDocs":4492778,
                                  "maxDocs":4497180
                               }
                            }
                         }
                      },
                      {
                         "script_score":{
                            "query":{
                               "bool":{
                                  "filter":{
                                     "term":{
                                        "title":"pray"
                                     }
                                  }
                               }
                            },
                            "script":{
                               "source":"params.termFreq * Math.log10((params.doCount - (params.allDocFreq  * params.numDocs\/params.maxDocs) + 1) \/ (params.allDocFreq * params.numDocs\/params.maxDocs)) \/ Math.log10(1 + params.doCount) * 1000 \/5",
                               "params":{
                                  "termFreq":188,
                                  "titleDocFreq":188,
                                  "allDocFreq":421,
                                  "doCount":3909828,
                                  "numDocs":4492778,
                                  "maxDocs":4497180
                               }
                            }
                         }
                      },
                      {
                         "script_score":{
                            "query":{
                               "bool":{
                                  "filter":{
                                     "term":{
                                        "title":"mosques"
                                     }
                                  }
                               }
                            },
                            "script":{
                               "source":"params.termFreq * Math.log10((params.doCount - (params.allDocFreq  * params.numDocs\/params.maxDocs) + 1) \/ (params.allDocFreq * params.numDocs\/params.maxDocs)) \/ Math.log10(1 + params.doCount) * 1000 \/5",
                               "params":{
                                  "termFreq":61,
                                  "titleDocFreq":61,
                                  "allDocFreq":182,
                                  "doCount":3909828,
                                  "numDocs":4492778,
                                  "maxDocs":4497180
                               }
                            }
                         }
                      }
                   ],
                   "query":{
                      "match":{
                         "title":{
                            "query":"jordan faithful return pray mosques",
                            "minimum_should_match":2
                         }
                      }
                   }
                }
             }
          }
       },
       "track_scores":true,
       "min_score":38,
       "sort":[
          {
             "unknown_language":{
                "order":"asc"
             }
          },
          {
             "_score":{
                "order":"desc"
             },
             "release_time":{
                "order":"desc"
             }
          }
       ]
    }

and i got this error

{
   "error":{
      "root_cause":[
         {
            "type":"parsing_exception",
            "reason":"script_score query does not support [query]",
            "line":1,
            "col":156
         }
      ],
      "type":"x_content_parse_exception",
      "reason":"[1:156] [bool] failed to parse field [must]",
      "caused_by":{
         "type":"parsing_exception",
         "reason":"script_score query does not support [query]",
         "line":1,
         "col":156
      }
   },
   "status":400
}

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