0
votes

Caused by: org.elasticsearch.common.ParsingException: [bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]

here is my request way :

    {
      "bool": {
          "must": [
            {
                "range": {
                    "timestamp": {
                        "gt": ${timestamp_from},
                        "lt": ${timestamp_to},
                        "include_lower": true,
                        "include_upper": false
                    }
                }
            }
          ]
        },
      "aggs": {
        "max_timestamp": {
        "max": {
        "field": "timestamp"
        }
    }
  }
}
1

1 Answers

0
votes

Your query has several issues, and they are quickly discoverable when you look at some ES query examples.

  • Root key should be query
  • aggs key should go after query, not after bool
  • ES has no idea what ${timestamp_from} and ${timestamp_to} are

So the correct query might be

{
   "query": {
      "bool": {
          "must": [
            {
                "range": {
                    "timestamp": {
                        "gt": 1409795880274,
                        "lt": 1509795880274,
                        "include_lower": true,
                        "include_upper": false
                    }
                }
            }
          ]
        }
},
      "aggs": {
        "max_timestamp": {
        "max": {
        "field": "timestamp"
        }
    }
  }
}