Javascript convert query string to Query DSL

Hi, is there a way to convert a user input string to Query DSL in Node? I notice that searchBar in ElasticUI framework can convert a string to Query DSL object. I'm wondering whether there is a way to convert an input string to DSL object on server side. Thanks in advance!

Example:
User input: a reason:b
Converted Query DSL:

{
  "bool": {
    "must": [
      {
        "simple_query_string": {
          "query": "a"
        }
      },
      {
        "match": {
          "reason": {
            "query": "b",
            "operator": "and"
          }
        }
      }
    ]
  }
}

@Bargs can we please get some help?

Thanks,
Bhavya

The best way to do this is with our new KQL language (referred to as kuery in the code). You can find the tools for parsing it and generating ES queries here: https://github.com/elastic/kibana/blob/8a83955650432e977d1d75adaab0aa4638cefe8a/packages/kbn-es-query/README.md#kuery

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