# \[function\_score\] malformed query, expected \[END\_OBJECT\] but found \[FIELD\_NAME\]

**URL:** <https://discuss.elastic.co/t/function-score-malformed-query-expected-end-object-but-found-field-name/245759>\
**Category:** Elasticsearch\
**Created:** [August 20, 2020, 12:12pm UTC](https://discuss.elastic.co/t/function-score-malformed-query-expected-end-object-but-found-field-name/245759 "2020-08-20T12:12:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijeet\_sinha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijeet_sinha/32/72790_2.png) [@abhijeet\_sinha](https://discuss.elastic.co/u/abhijeet_sinha)\
**Post date:** [August 20, 2020, 12:12pm UTC](https://discuss.elastic.co/t/function-score-malformed-query-expected-end-object-but-found-field-name/245759/1 "2020-08-20T12:12:50Z")

</div>

What's wrong with this query?

```auto
GET /catalog/_search
{"query": {
 "function_score": {
   "boost_mode": "multiply",
   "functions": [
     {
       "field_value_factor": {
         "field": "boostFactor",
         "factor": 1,
         "missing": 1
       }
     }
   ],
   "query": {
     "dis_max": {
       "queries": [
         {
           "bool": {
             "should": [
               {
                 "multi_match": {
                   "query": "cloth",
                   "type": "cross_fields",
                   "fields": [
                     "keywords.nouns^6",
                     "name^5",
                     "brand.brandName^4",
                     "category.categoryName^3",
                     "family.familyName^2",
                     "attributeValues",
                     "mpn^2",
                     "tags",
                     "category.rootCategoryName^3",
                     "category.level1CategoryName^3",
                     "category.level2CategoryName^3",
                     "category.level3CategoryName^3"
                   ],
                   "minimum_should_match": "2<75%"
                 }
               }
             ],
             "must_not": [
               {
                 "term": {
                   "isActive": false
                 }
               }
             ]
           }
         },
         {
           "multi_match": {
             "query": "cloth",
             "analyzer": "whitespace",
             "fields": [
               "id^3"
             ]
           }
         },
         {
           "bool": {
             "must": [
               {
                 "match_phrase_prefix": {
                   "partial_id": "cloth"
                 }
               }
             ],
             "must_not": [
               
             ],
             "should": [
               
             ]
           }
         }
       ]
     }
   }
 },"bool": {
   "must": [
     {
       "term": {
         "isActive": {
           "value": true
         }
       }
     }
   ],
   "must_not": [
     {
       "term": {
         "family.familyId": {
           "value": 0
         }
       }
     }
   ],
   "should": [
     {
       "terms": {
         "feefoAvgRating": [
           "5",
           "4"
         ]
       }
     },
     {
       "terms": {
         "industries": [
           21
         ]
       }
     }
   ]
 }}}

```

It errors when i include `bool` query after `function_score`, works fine without bool query.

---

<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:** [September 17, 2020, 12:13pm UTC](https://discuss.elastic.co/t/function-score-malformed-query-expected-end-object-but-found-field-name/245759/2 "2020-09-17T12:13:18Z")

</div>

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