Best Way to Convert Dynamic Frontend Filters to Elasticsearch Query DSL (Deeply Nested + AND/OR Support)

Hi everyone,

I'm working on a frontend application that includes a flexible filter UI, allowing users to build complex search conditions using nested groups and logical operators (AND, OR). Each filter has a structure like:

{
  "field": "action",
  "operator": "is one of",
  "value": ["blocked", "allowed"]
}

We also support nested conditions like:

{
  "logic": "and",
  "conditions": [
    { "field": "tags", "operator": "exists" },
    {
      "logic": "or",
      "conditions": [
        { "field": "score", "operator": "<", "value": 10 },
        { "field": "severity", "operator": "is", "value": "High" }
      ]
    }
  ]
}

We're currently trying to convert this frontend structure into Elasticsearch Query DSL with the correct nesting and logic.

Is there an official or recommended approach or library from Elastic to convert structured filters into Elasticsearch queries? We can update the input but as per operator we need to build Elasticsearch query is there any apis or functions available for it ?