# Increase the score of the last resource of each type

**URL:** <https://discuss.elastic.co/t/increase-the-score-of-the-last-resource-of-each-type/191846>\
**Category:** Elasticsearch\
**Created:** [July 23, 2019, 2:50pm UTC](https://discuss.elastic.co/t/increase-the-score-of-the-last-resource-of-each-type/191846 "2019-07-23T14:50:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael.m](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@raphael.m](https://discuss.elastic.co/u/raphael.m)\
**Post date:** [July 23, 2019, 2:50pm UTC](https://discuss.elastic.co/t/increase-the-score-of-the-last-resource-of-each-type/191846/1 "2019-07-23T14:50:47Z")

</div>

Hello friends,

I'm facing a problem and i really don't know how handle it.  
Actually I have a "simple" research on a class called "Resource". These resources have a specific type but are show in a unique list with all the types. All the search part is working with different filters etc.

What I want to do is to increase the score (x10) of the last (date) resource of each type.  
For example I actually have :  
Resource 4 - Type C - Date 21/01/2019  
Resource 7 - Type C - Date 20/01/2019  
Resource 5 - Type A - Date 18/01/2019  
Resource 2 - Type A - Date 17/01/2019  
Resource 6 - Type C - Date 17/01/2019  
Resource 3 - Type B - Date 12/01/2019  
Resource 1 - Type B - Date 10/01/2019  
And I want :  
Resource 4 - Type C - Date 21/01/2019 -\> score x10  
Resource 5 - Type A - Date 18/01/2019 -\> score x10  
Resource 3 - Type B - Date 12/01/2019 -\> score x10  
Resource 7 - Type C - Date 20/01/2019  
Resource 2 - Type A - Date 17/01/2019  
Resource 6 - Type C - Date 17/01/2019  
Resource 1 - Type B - Date 10/01/2019

I hope this is comprehensible and you understand my needs  
Thanks for you attention and help 🙂

---

<div class="post-metadata">

**Author:** ![raphael.m](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@raphael.m](https://discuss.elastic.co/u/raphael.m)\
**Post date:** [August 14, 2019, 2:19pm UTC](https://discuss.elastic.co/t/increase-the-score-of-the-last-resource-of-each-type/191846/2 "2019-08-14T14:19:24Z")

</div>

Little up! to maintain visibility 🙂

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 15, 2019, 7:33am UTC](https://discuss.elastic.co/t/increase-the-score-of-the-last-resource-of-each-type/191846/3 "2019-08-15T07:33:43Z")

</div>

are you really interested in scoring those up or do you really want them to be the top matches and displayed at the top of your list?

if the latter, how about executing two searches:

1. The first uses [field collapsing](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-request-body.html#request-body-search-collapse) against the resource and sorts by timestamp.
2. the second executes your regular query (you could exclude the id's of the documents found in the first search request so they do not show up in your result set).

Would that work or is your use-case different?

---

<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:** [September 12, 2019, 7:33am UTC](https://discuss.elastic.co/t/increase-the-score-of-the-last-resource-of-each-type/191846/4 "2019-09-12T07:33:54Z")

</div>

Closed on September 12, 2019, 7:33am UTC

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