Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions explore-analyze/_snippets/multi-value-esql-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ You can create controls that let users select multiple values. To do that:
Multi-selection is only available for `?values` variables. It is not available for `??fields` and `??functions` variables.
:::

2. When defining the control, select the **Allow multiple selections** option.
:::{note}
[`MV_CONTAINS`](elasticsearch://reference/query-languages/esql/functions-operators/mv-functions/mv_contains.md) will check if _all_ values are present, use [`MV_INTERSECTS`](elasticsearch://reference/query-languages/esql/functions-operators/mv-functions/mv_intersects.md) if you want _any_ present semantics.
Comment thread
mjmbischoff marked this conversation as resolved.
Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Can you explain to me which is the difference between MV_CONTAINS with the MV_INTERSECTS we want to add here?

@mjmbischoff mjmbischoff Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one checks if all values are present in the field, the other will return true if any values are present.

So if you have a field with for example cloud provider [AWS, AZURE, GCP] you can ask "give me all services deployed in AWS and AZURE" vs "Give me all services in AZURE or GCP"

PUT services
{
    "mappings": {
        "properties": {
            "name": {
                "type": "keyword"
            },
            "location": {
                "properties": {
                    "cloud": {
                        "type" : "keyword"
                    }
                }
            }
        }
    }
}


PUT services/_doc/a
{
  "name": "service A",
  "location" : {
    "cloud": ["AZURE", "AWS", "GCP"]
  }
}
PUT services/_doc/b
{
  "name": "service B",
  "location" : {
    "cloud": ["AZURE", "AWS"]
  }
}
PUT services/_doc/c
{
  "name": "service C",
  "location" : {
    "cloud": [ "AWS", "GCP"]
  }
}
PUT services/_doc/d
{
  "name": "service D",
  "location" : {
    "cloud": ["AZURE", "GCP"]
  }
}
PUT services/_doc/e
{
  "name": "service E",
  "location" : {
    "cloud": ["AZURE"]
  }
}

POST services/_refresh

POST _query?format=txt
{
  "query": """
    FROM services 
    | WHERE MV_CONTAINS(location.cloud, ["AZURE","AWS"])
  """
}

/*
#! No limit defined, adding default limit of [1000]
 location.cloud  |     name      
-----------------+---------------
[AWS, AZURE, GCP]|service A      
[AWS, AZURE]     |service B         
*/

POST _query?format=txt
{
  "query": """
    FROM services 
    | WHERE MV_INTERSECTS(location.cloud, ["AZURE","AWS"])
  """
}

/*
#! No limit defined, adding default limit of [1000]
 location.cloud  |     name      
-----------------+---------------
AZURE            |service E      
[AWS, AZURE, GCP]|service A      
[AWS, AZURE]     |service B      
[AWS, GCP]       |service C      
[AZURE, GCP]     |service D     
*/
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm both support multi values variables. So it is ok to update the docs but also this:

image

:::

3. When defining the control, select the **Allow multiple selections** option.

3. Save the control.
4. Save the control.

The newly configured control becomes available and allows users to select multiple values.
Loading