# Sort results by page views

**URL:** <https://discuss.elastic.co/t/sort-results-by-page-views/197859>\
**Category:** Elasticsearch\
**Created:** [September 3, 2019, 12:43pm UTC](https://discuss.elastic.co/t/sort-results-by-page-views/197859 "2019-09-03T12:43:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dojutsu-user](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dojutsu-user/32/46428_2.png) [@dojutsu-user](https://discuss.elastic.co/u/dojutsu-user)\
**Post date:** [September 3, 2019, 12:43pm UTC](https://discuss.elastic.co/t/sort-results-by-page-views/197859/1 "2019-09-03T12:43:11Z")

</div>

I have an Elasticsearch cluster with lots of pages indexed. I am using Elasticsearch to provide best results to the users currently. Each page is viewed many times in a day. I want to store the page view count and take this value (page view count) to boost the results.  
For example: if a result is ranked 3rd but its page view count is very much, then it should rank 2nd or maybe 1st.

I need help in achieving this target.

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [September 3, 2019, 2:03pm UTC](https://discuss.elastic.co/t/sort-results-by-page-views/197859/2 "2019-09-03T14:03:34Z")

</div>

Hi @dojutsu-user,

I think the more efficient way i to store the views as logs in hourly, daily, weekly, monthly index depends on your needs.

You can store what ever data you think it's had a value.

> {  
> "url\_page": "sort-results-by-page-views/197859",  
> "product": "sort-results-by-page-views",  
> "product\_id": "197859"  
> "created\_at": "2019-09-03 12:34:11"  
> }

You can run a script with an aggregation and update a weight field in your indexed pages that you can use on search to boost.

This solution is quick and dirty but depend on your needs it can be ok.

Solution 2 but experimental:

> **[Ranking evaluation API | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html)**

Or:

> **[GitHub - o19s/elasticsearch-learning-to-rank: Plugin to integrate Learning to...](https://github.com/o19s/elasticsearch-learning-to-rank)**
>
> Plugin to integrate Learning to Rank (aka machine learning for better relevance) with Elasticsearch - GitHub - o19s/elasticsearch-learning-to-rank: Plugin to integrate Learning to Rank (aka machine...

---

<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:** [October 1, 2019, 2:03pm UTC](https://discuss.elastic.co/t/sort-results-by-page-views/197859/3 "2019-10-01T14:03:35Z")

</div>

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