0

How to use Kibana query in Rest API.

My Query.

GET _search?&filter_path=hits.hits._source
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {"Status": "New"}
        },
        {
          "match": {"Locked": "False"}
        },
        {
         "range" : {
            "Date" : {
                "gte" : "now-1w/d",
                "lt" :  "now/d"
            }
        }
        }
      ]
    }
  }
}

i have tried below Example .

http://localhost:9200/_search?&filter_path=hits.hits._source%20{%20%22query%22:%20{%20%22bool%22:%20{%20%22must%22:%20[%20{%20%22match%22:%20{%22Status%22:%20%22New%22}%20},%20{%20%22match%22:%20{%22Locked%22:%20%22False%22}%20},%20{%20%22range%22%20:%20{%20%22Date%22%20:%20{%20%22gte%22%20:%20%22now-1w/d%22,%20%22lt%22%20:%20%22now/d%22%20}%20}%20}%20]%20}%20}%20}

But it will Return {}

please help me to done.

1 Answer 1

1

You can pass the JSON query in the HTTP query string by passing the JSON query in the source query string parameter and specifying the source_content_type=application/json parameter.

Like this:

http://localhost:9200/_search?filter_path=hits.hits._source&source_content_type=application/json&source={"query":{"bool":{"must":[{"match":{"Status":"New"}},{"match":{"Locked":"False"}},{"range":{"Date":{"gte":"now-1w/d","lt":"now/d"}}}]}}}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.