# Incorrect query and I don't understand why

**URL:** <https://discuss.elastic.co/t/incorrect-query-and-i-dont-understand-why/364936>\
**Category:** Kibana\
**Created:** [August 15, 2024, 1:48am UTC](https://discuss.elastic.co/t/incorrect-query-and-i-dont-understand-why/364936 "2024-08-15T01:48:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoann\_Buzenet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yoann_buzenet/32/133522_2.png) [@Yoann\_Buzenet](https://discuss.elastic.co/u/Yoann_Buzenet)\
**Post date:** [August 15, 2024, 1:48am UTC](https://discuss.elastic.co/t/incorrect-query-and-i-dont-understand-why/364936/1 "2024-08-15T01:48:00Z")

</div>

Hello,

I created a query that doesn't work and the kibana devtools is not showing me a syntax error. There must be something logical I missed. I wonder if it comes from the multiples "should" clauses I am using. Could you tell me if you see something incorrect in the following query?

I get this output:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
        "line": 1071,
        "col": 6
      }
    ],
    "type": "parsing_exception",
    "reason": "[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
    "line": 1071,
    "col": 6
  },
  "status": 400
}

```

Here is the query:

```auto

```

---

<div class="post-metadata">

**Author:** ![nfeekery](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nfeekery/32/117349_2.png) [@nfeekery](https://discuss.elastic.co/u/nfeekery)\
**Post date:** [August 15, 2024, 8:15am UTC](https://discuss.elastic.co/t/incorrect-query-and-i-dont-understand-why/364936/2 "2024-08-15T08:15:35Z")

</div>

From #Elastic Search to #Kibana

---

<div class="post-metadata">

**Author:** ![Yoann\_Buzenet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yoann_buzenet/32/133522_2.png) [@Yoann\_Buzenet](https://discuss.elastic.co/u/Yoann_Buzenet)\
**Post date:** [August 15, 2024, 11:58am UTC](https://discuss.elastic.co/t/incorrect-query-and-i-dont-understand-why/364936/3 "2024-08-15T11:58:38Z")

</div>

I found out, it was coming from using should in `query.query`, which it seems can not be used in the same time with `query.function_score.query.bool`

Passing everything in `query.function_score.query.bool` makes it work again

I don't understand why but it works

---

<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 12, 2024, 11:58am UTC](https://discuss.elastic.co/t/incorrect-query-and-i-dont-understand-why/364936/4 "2024-09-12T11:58:40Z")

</div>

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