# Elasticsearch Malformed Query, Expected \[END\_OBJECT\] but found \[Field\_Name\]

**URL:** <https://discuss.elastic.co/t/elasticsearch-malformed-query-expected-end-object-but-found-field-name/329072>\
**Category:** Elasticsearch\
**Created:** [March 31, 2023, 5:31pm UTC](https://discuss.elastic.co/t/elasticsearch-malformed-query-expected-end-object-but-found-field-name/329072 "2023-03-31T17:31:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elrozario](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@elrozario](https://discuss.elastic.co/u/elrozario)\
**Post date:** [March 31, 2023, 5:31pm UTC](https://discuss.elastic.co/t/elasticsearch-malformed-query-expected-end-object-but-found-field-name/329072/1 "2023-03-31T17:31:29Z")

</div>

Hello,  
I am trying to run reindex with query but getting the error Malformed Query, Expected [END\_OBJECT] but found [Field\_Name].

```plaintext
{
  "source": {
    "index": "index-*",
    "_source" : ["@timestamp", "message"],
    "query": {
      "bool": {
        "filter": [
          {
           "term": {
            "log.file.path": "server.log"
           },
           "range": {
             "@timestamp": {
               "gte": "now-2d/d",
               "lte": "now/d"
             }
           }
          }
        ],
        "should": [
             {
            "match_phrase": {
              "message": "response"
             }
           },
          {
           "match_phrase": {
              "message": "request"
            }
          }
        ],
        "minimum_should_match": 1
      }
    }
  },
  "dest": {
    "index": "test-001"
  }
}

```

(I am trying to filter documents from the index with that contains "log.file.path" as "server.log", either contains "request" or "response" and also trying to get only the last 24 hours documents. Everything else works if I remove the range @timestamp part)

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [March 31, 2023, 6:15pm UTC](https://discuss.elastic.co/t/elasticsearch-malformed-query-expected-end-object-but-found-field-name/329072/2 "2023-03-31T18:15:16Z")

</div>

Hi @elrozario

The error is in Filter.

Try this:

```auto
"filter": [
          {
            "term": {
              "log.file.path": "server.log"
            }
          },
          {
            "range": {
              "@timestamp": {
                "gte": "now-2d/d",
                "lte": "now/d"
              }
            }
          }
        ]

```

---

<div class="post-metadata">

**Author:** ![elrozario](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@elrozario](https://discuss.elastic.co/u/elrozario)\
**Post date:** [March 31, 2023, 7:33pm UTC](https://discuss.elastic.co/t/elasticsearch-malformed-query-expected-end-object-but-found-field-name/329072/3 "2023-03-31T19:33:54Z")

</div>

Hi @RabBit_BR

Thank you for the solution.

This is working after I modified the "filter" as you advised.

Regards,  
Elizabeth

---

<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:** [April 28, 2023, 7:33pm UTC](https://discuss.elastic.co/t/elasticsearch-malformed-query-expected-end-object-but-found-field-name/329072/4 "2023-04-28T19:33:58Z")

</div>

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