# Getting recent searched result

**URL:** <https://discuss.elastic.co/t/getting-recent-searched-result/210482>\
**Category:** Elasticsearch\
**Created:** [December 4, 2019, 7:32am UTC](https://discuss.elastic.co/t/getting-recent-searched-result/210482 "2019-12-04T07:32:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afiq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/afiq/32/45680_2.png) [@afiq](https://discuss.elastic.co/u/afiq)\
**Post date:** [December 4, 2019, 7:32am UTC](https://discuss.elastic.co/t/getting-recent-searched-result/210482/1 "2019-12-04T07:32:20Z")

</div>

Hi guys. I'm pretty new with elasticsearch. How do I write a query to get results of most recent searched documents and sorted. For example if I used to search that specific document, when I come back and search it again, it will be always at the top of the result list.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 4, 2019, 8:32am UTC](https://discuss.elastic.co/t/getting-recent-searched-result/210482/2 "2019-12-04T08:32:11Z")

</div>

Welcome!

Elasticsearch does not provide such a feature as it does not recall which documents have been served in the past or what the user selected at the end.

You probably have to implement something like this "manually". Using [pinned query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-pinned-query.html) might help.

---

<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:** [January 1, 2020, 8:32am UTC](https://discuss.elastic.co/t/getting-recent-searched-result/210482/3 "2020-01-01T08:32:17Z")

</div>

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