# Setting, to automatically register queries in an "query" Index

**URL:** <https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629>\
**Category:** Elasticsearch\
**Created:** [September 15, 2016, 4:02pm UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629 "2016-09-15T16:02:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xavier.tiendeo](https://avatars.discourse-cdn.com/v4/letter/x/e8c25b/32.png) [@xavier.tiendeo](https://discuss.elastic.co/u/xavier.tiendeo)\
**Post date:** [September 15, 2016, 4:02pm UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629/1 "2016-09-15T16:02:40Z")

</div>

Is there a transitional setting to automatically register queries as documents in an specific index. I see Percolate but is not exactly the same and also slowqueries, but in this case it goes to a file and you have to have for example Logstash to index them to Elastic.

Would be useful to have the possibility to direct update a setting and begin indexing them and then update it to no do it.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [September 15, 2016, 4:09pm UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629/2 "2016-09-15T16:09:25Z")

</div>

What's your goal? Are you wanting to register/save queries so you can use them later as a query you execute? E.g. sorta like stored procedures in SQL databases?

Or are you wanting to log the queries being executed, to check for slow queries, see what keywords users are querying, etc?

---

<div class="post-metadata">

**Author:** ![xavier.tiendeo](https://avatars.discourse-cdn.com/v4/letter/x/e8c25b/32.png) [@xavier.tiendeo](https://discuss.elastic.co/u/xavier.tiendeo)\
**Post date:** [September 16, 2016, 6:31am UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629/3 "2016-09-16T06:31:46Z")

</div>

Not really, is more for profile purposes, for example for knowing the queries that some application is doing to elastic, despite it are slow or not

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [September 16, 2016, 1:38pm UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629/4 "2016-09-16T13:38:33Z")

</div>

Ah, ok. In that case, there isn't a good, automated way to do it at the moment. The best way to accomplish this is by collecting the queries as they are executed from your application. If you can't do that, the slowlog is the next best. If you set the slowlog to 0ms threshold, it logs all queries.

This obviously isn't ideal, since the log format is somewhat difficult to parse, and queries are recorded on a per-shard basis. But it can work.

We'd like to have better collection of queries in the future, it just hasn't been done yet.

Note: the Shield plugin can do audit logging, so that you know what endpoints users are executing. So that may work for you, depending on your requirements.

---

<div class="post-metadata">

**Author:** ![xavier.tiendeo](https://avatars.discourse-cdn.com/v4/letter/x/e8c25b/32.png) [@xavier.tiendeo](https://discuss.elastic.co/u/xavier.tiendeo)\
**Post date:** [September 16, 2016, 2:18pm UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629/5 "2016-09-16T14:18:12Z")

</div>

Ok, thanks would be nice having it by default 🙂 thanks!

---

<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 5, 2017, 10:19pm UTC](https://discuss.elastic.co/t/setting-to-automatically-register-queries-in-an-query-index/60629/6 "2017-07-05T22:19:37Z")

</div>


