# Best way to save users search queries in ElasticSearch?

**URL:** <https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518>\
**Category:** Elasticsearch\
**Created:** [April 15, 2016, 3:32pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518 "2016-04-15T15:32:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fridary](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@fridary](https://discuss.elastic.co/u/fridary)\
**Post date:** [April 15, 2016, 3:32pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/1 "2016-04-15T15:32:27Z")

</div>

I am developing application that uses ElasticSearch and SQL database. So, what is the best way to save users search queries and show statistics like what are the most popular requests? The simply way is to save in SQL database and count. But maybe there are some technique built in ElasticSearch?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 15, 2016, 10:19pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/2 "2016-04-15T22:19:02Z")

</div>

There isn't currently a way to do that, ES doesn't track information to that level.  
If you want to track queries you will need to put a proxy in front of ES.

---

<div class="post-metadata">

**Author:** ![fridary](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@fridary](https://discuss.elastic.co/u/fridary)\
**Post date:** [April 16, 2016, 5:30pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/3 "2016-04-16T17:30:44Z")

</div>

Thank you for your reply.  
What is proxy?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 16, 2016, 8:16pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/4 "2016-04-16T20:16:18Z")

</div>

> **[Proxy server](https://en.wikipedia.org/wiki/Proxy_server)**
>
> In computer networks, a proxy server is a server (a computer system or an application) that acts as an intermediary for requests from clients seeking resources from other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource available from a different server and the proxy server evaluates the request as a way to simplify and control its complexity. Proxies were invented to add structure and encapsulation to distributed

---

<div class="post-metadata">

**Author:** ![fridary](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@fridary](https://discuss.elastic.co/u/fridary)\
**Post date:** [April 17, 2016, 8:23am UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/5 "2016-04-17T08:23:49Z")

</div>

Your answer did not help me. I have not found any ideas/solutions/tips how proxy can be connected with ES, how to integrate/use proxy with ES and solve my problem.

---

<div class="post-metadata">

**Author:** ![fridary](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@fridary](https://discuss.elastic.co/u/fridary)\
**Post date:** [April 22, 2016, 3:24pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/6 "2016-04-22T15:24:04Z")

</div>

up....

---

<div class="post-metadata">

**Author:** ![unknownunknown](https://avatars.discourse-cdn.com/v4/letter/u/4da419/32.png) [@unknownunknown](https://discuss.elastic.co/u/unknownunknown)\
**Post date:** [April 22, 2016, 3:41pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/7 "2016-04-22T15:41:59Z")

</div>

I think that adding a proxy server would allow you to log the GET/POST requests made to elasticsearch. This link shows how to configure access logs in the NGINX server. [https://www.nginx.com/resources/admin-guide/logging-and-monitoring/](https://www.nginx.com/resources/admin-guide/logging-and-monitoring/). Note that you would somehow need to get the body of these requests for a comprehensive record of the requests.

Alternatively, you could write/find a local service that would allow you to store requests to ES in ES, and later retrieve and execute them.

---

<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:56pm UTC](https://discuss.elastic.co/t/best-way-to-save-users-search-queries-in-elasticsearch/47518/8 "2017-07-05T22:56:58Z")

</div>


