# Consider recent documents when querying?

**URL:** <https://discuss.elastic.co/t/consider-recent-documents-when-querying/140182>\
**Category:** Elasticsearch\
**Created:** [July 16, 2018, 3:36pm UTC](https://discuss.elastic.co/t/consider-recent-documents-when-querying/140182 "2018-07-16T15:36:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESCoder](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@ESCoder](https://discuss.elastic.co/u/ESCoder)\
**Post date:** [July 16, 2018, 3:36pm UTC](https://discuss.elastic.co/t/consider-recent-documents-when-querying/140182/1 "2018-07-16T15:36:06Z")

</div>

Hi,  
i was wondering if you guys can help me, we are using ES 6 version and NEST for queries.  
Our document structure has a recently modified date.

In NEST, is there a way we can tell the query to consider more recent documents when searching?

I dont want to do post-filtering of results to sort them by their latest modified date.

Is there any provisions for that?  
thanks

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 20, 2018, 12:45pm UTC](https://discuss.elastic.co/t/consider-recent-documents-when-querying/140182/2 "2018-07-20T12:45:35Z")

</div>

I don't exactly know how to do this with the NEST client, but to include the recently modified date into your scoring function you would typically use the [function score query](https://www.google.com/search?q=function+score+query+elasticsearch&ie=utf-8&oe=utf-8&client=firefox-b). If it is enough to just sort the top K search hits by the modified date, you can also look into [Rescoring](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html) by sorting on that field.

---

<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:** [August 17, 2018, 12:49pm UTC](https://discuss.elastic.co/t/consider-recent-documents-when-querying/140182/3 "2018-08-17T12:49:03Z")

</div>

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