# Kibana: Create tag or field based on conditional query

**URL:** https://discuss.elastic.co/t/kibana-create-tag-or-field-based-on-conditional-query/54073
**Category:** Kibana
**Created:** [June 27, 2016, 7:43pm UTC](https://discuss.elastic.co/t/kibana-create-tag-or-field-based-on-conditional-query/54073 "2016-06-27T19:43:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![khall](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@khall](https://discuss.elastic.co/u/khall)
#### Post date: [June 27, 2016, 7:43pm UTC](https://discuss.elastic.co/t/kibana-create-tag-or-field-based-on-conditional-query/54073/1 "2016-06-27T19:43:49Z")

</div>

New to Kibana/ES; need syntax help.

I have a query w/3 filter conditions that basically goes like this: If Type="movement" and X=32 AND Y=33, then label this document as "Hazard".

I can get the query filters to work (Type:"movement" AND X:32 AND Y:33). But, how do I then label these documents as "Hazard" so that I can do additional queries on just the term "Hazard"??? Do I create a tag, a field, or something else? How do I do that?

---

<div class="post-metadata">

### Author: ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)
#### Post date: [June 27, 2016, 9:13pm UTC](https://discuss.elastic.co/t/kibana-create-tag-or-field-based-on-conditional-query/54073/2 "2016-06-27T21:13:17Z")

</div>

Is sounds like you already have this part figured out - but you can edit a filter and utilize the [boolean query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html) to achieve what you're looking for:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/2110327d119c6ab0672b373deaff1dd3378dd66f.png)

In regards to utilizing a field to make it easier to lookup: The best option would be to add the field to the document when it's indexed. I understand that this is not always possible. Another option would be to use a scripted field. This would work for general querying, but won't work for visualizations when the field is used for aggregations.

---

<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: [July 6, 2017, 1:49pm UTC](https://discuss.elastic.co/t/kibana-create-tag-or-field-based-on-conditional-query/54073/3 "2017-07-06T13:49:06Z")

</div>


