# Terms Query by index in dashboards

**URL:** <https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language\
**Created:** [September 5, 2022, 9:32pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717 "2022-09-05T21:32:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadelkareem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gadelkareem/32/71031_2.png) [@gadelkareem](https://discuss.elastic.co/u/gadelkareem)\
**Post date:** [September 5, 2022, 9:32pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717/1 "2022-09-05T21:32:49Z")

</div>

I am currently using [Terms Query by index](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html#query-dsl-terms-lookup-params) to filter a query:

```auto
{
          "query": {
            "bool": {
              "must": [
                {
                  "terms": {
                    "test.type.name": {
                      "index": "test-type-index",
                      "id": "unit-test",
                      "path": "type.name"
                    }
                  }
                },
                {
                  "term": {
                    "test.env": {
                      "value": "dev"
                    }
                  }
                }
              ]
            }
          }
    }

```

Example of `test-type-index`:

```auto
{
        "_index": "test-type-index",
        "_id": "unit-test",
        "_score": 1.0,
        "_source": {
          "type": [
            {
              "name": "test1",
            },
            {
              "name": "test2",
            }
          ]
        }
      }
}

```

I am trying to create a dashboard based on this query.  
How can I create these visualisations?

- Create visualisation based on the above query. I managed to use DSL to filter the results in discover using this query but not the visualisation.
- Create an option list of test-type-index ids then use the type names to filter another visualisation.

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [September 26, 2022, 12:14pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717/2 "2022-09-26T12:14:44Z")

</div>

Hey there, did you find your response? What kind of visualization do you have in mind?

---

<div class="post-metadata">

**Author:** ![gadelkareem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gadelkareem/32/71031_2.png) [@gadelkareem](https://discuss.elastic.co/u/gadelkareem)\
**Post date:** [September 26, 2022, 12:36pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717/3 "2022-09-26T12:36:37Z")

</div>

No, it is not possible to use DSL inside the visualisation. And using option list in the query is a feature that ES team is working on AFAIK.

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [September 26, 2022, 12:39pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717/4 "2022-09-26T12:39:20Z")

</div>

Yes, but you still can filter the visualization by dsl query filter. You cannot use dsl as a visualization source though.

 ![Screenshot 2022-09-26 at 14.38.31](https://us1.discourse-cdn.com/elastic/original/3X/f/9/f9766d2800757e0accde00acf7665e7668ee641d.jpeg)

---

<div class="post-metadata">

**Author:** ![gadelkareem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gadelkareem/32/71031_2.png) [@gadelkareem](https://discuss.elastic.co/u/gadelkareem)\
**Post date:** [September 26, 2022, 1:52pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717/5 "2022-09-26T13:52:00Z")

</div>

I understand, but I am looking for a way to use DSL in the visualisation.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 24, 2022, 1:52pm UTC](https://discuss.elastic.co/t/terms-query-by-index-in-dashboards/313717/6 "2022-10-24T13:52:30Z")

</div>

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