How to enter Elastic JSON query in Kibana discover

I´m trying to use this one in Kibana discover but it expects some other format i think.
Error: Discover: Expected "*", ":", "<", "<=", ">", ">=", "", [\ \t\r\n] or end of input but """ found
The query looks like this:

{   "size":0,
    "query": {
        "range": {
            "mainBattery": {
                "lte": 89,
                "gte": 80
            }
        }
    },
    "collapse": {
        "field": "mac.keyword"
    },
    "sort": [
        {
            "timestamp": "desc"
        }
    ],
    "aggs": {
        "result_count": {
            "cardinality": {
                "field": "mac.keyword"
            }
        }
    }
}

Is it possible? In other words how can i perform this query in discover ?`Later i want to use the query incl. aggs in Visualization.

Hey @dirri, you unfortunately can't directly input the Elasticsearch search syntax directly into Discover or Visualize. Using the "filter bar" at the top of both Visualize and Discover, you can input the filter:

"query": {
        "range": {
            "mainBattery": {
                "lte": 89,
                "gte": 80
            }
        }
    },

On Discover, this will show you all of the documents that match the specific filter.

And then if you switch over to Visualize, you can build the rest of the visualization using the cardinality aggregation.

Hi @Brandon_Kobel, thx for the reply but i didn't See the cardinality aggregation in visualize and i also need the collapsing and timstamp sorting to get desired result. Any idea?

Or am i missing something?

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