'Any way(plugin) to parse kibana query syntax to elasticsearch api body?

I have a search engine app which does not use kibana. I want to translate query like (mysql.method: INSERT OR mysql.method: UPDATE) AND responsetime: [30 TO 50) into rest api body:

{
    "filtered" : {
      "filter" : {
        "and":[
          "or": [
            { "mysql.method" : "INSERT" },
            { "mysql.method" : "UPDATE" }
          ],
          "range": {
            "responsetime": {
              "gte":30,
              "lt":50
            }
          }
        ]
      }
    }
  }

Is there any plugin to achieve this? Hopefully in js.



Solution 1:[1]

No need to use any plugin. You can use directly the query string query. It work with the same syntax as Kibana "search bar".

{
    "query_string" : {
        "query" : "(mysql.method:INSERT OR mysql.method:UPDATE) AND responsetime:[30 TO 50]"
    }
}

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1