opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.69k stars 893 forks source link

Feature request - DSL query control in controls visualisation #3357

Open levyitamar opened 1 year ago

levyitamar commented 1 year ago

Feature request

I have the following DSL query/filter on my entire dashboard, it makes sure that value1 is not equal to value2.

{
  "query": {
    "bool": {
      "must_not": [
        {
          "script": {
            "script": {
              "inline": "doc['value1.keyword'].value==doc['value2.keyword'].value",
              "lang": "painless"
            }
          }
        }
      ]
    }
  }
}

At the moment, controls visual has only two options switch and range slider which is very restricted as far as filtering ability. It would amazing if a DSL query could be incorporated as, for example an on/off switch, so queries such as the above example can be turned on and off using a control.

joshuarrrr commented 1 year ago

@levyitamar What you're describing is natively supported by the global filter controls. They support DSL query definitions and can be given custom names. Once created, they can be easily toggled off and on, be inverted, and pinned across multiple applications:

https://user-images.githubusercontent.com/1679762/217075607-9d5104e7-3f6b-4244-8715-382846c0f8d3.mov

In contrast, the "Controls" visualization is primarily intended to be a more user-friendly alternative for setting and changing simple filters that don't require knowledge of more complex concepts like DSL. So the restricted functionality is intentional as part of maintaining simplicity and ease of use.

CC @ahopp for additional perspective.

ahopp commented 1 year ago

@levyitamar thanks for opening!

I tend to agree with @joshuarrrr on this one - my perspective is that "controls" is meant to be the end user centric, super simple, easy to use, filter mechanism while the global filter controls is the means to more esoteric, nuanced, or complex filtering methods. In general, we have this distinction by intention.

That being said, perhaps we have a path to improving the "controls" visualization to support both. Since "controls", as I understand it, just wraps the filter API would could wrap anything as long as it would map to a toggle, slider, or input fields.

@kgcreative @KrooshalUX What do you all think? If we could provide dashboard/visualization authors a path to more bespoke filtering controls that doesn't erode the value of a very simple filter mechanism, I'd be supportive. Perhaps something like the filtering "Edit as Query DSL" (Figure A below) in the "Add" screen under the edit "Controls" visualization path (Figure B below)?

Figure A: "Edit as Query DSL" image

Figure B: "Edit" -> "Add" For Controls image