Sorting facets on score


(Yannick Smits-2) #1

Instead of sorting facets by document count is it possible to sort facets by
document score?


(Shay Banon) #2

You can use terms stats, and provide a value_script with "doc.score".
On Friday, May 20, 2011 at 3:38 PM, Yannick Smits wrote:

Instead of sorting facets by document count is it possible to sort facets by document score?


(Yannick Smits-2) #3

Thanks, got it to work with this syntax:

"facets" : {

"tag_book_stats" : {

"terms_stats" : {

"key_field" : "book.name",

"value_script"" : "doc.score"

}

}

}

But it shows me the score and the count now but still sorts on count instead of score.

From: Shay Banon [mailto:shay.banon@elasticsearch.com]
Sent: vrijdag 20 mei 2011 17:00
To: users@elasticsearch.com
Subject: Re: sorting facets on score

You can use terms stats, and provide a value_script with "doc.score".

On Friday, May 20, 2011 at 3:38 PM, Yannick Smits wrote:

Instead of sorting facets by document count is it possible to sort facets by document score?


(Shay Banon) #4

Check the ordering option in terms stats: http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html.

On Thursday, May 26, 2011 at 11:58 AM, Yannick Smits wrote:

Thanks, got it to work with this syntax:

"facets" : {

"tag_book_stats" : {

"terms_stats" : {

"key_field" : "book.name (http://book.name)",

"value_script"" : "doc.score"

}

}

}

But it shows me the score and the count now but still sorts on count instead of score.

From: Shay Banon [mailto:shay.banon@elasticsearch.com]
Sent: vrijdag 20 mei 2011 17:00
To: users@elasticsearch.com (mailto:users@elasticsearch.com)
Subject: Re: sorting facets on score

You can use terms stats, and provide a value_script with "doc.score".
On Friday, May 20, 2011 at 3:38 PM, Yannick Smits wrote:

Instead of sorting facets by document count is it possible to sort facets by document score?


(Yannick Smits-2) #5

Works perfectly!
I was staring on the word “sort” instead of “order”.

Thanks!

From: Shay Banon [mailto:shay.banon@elasticsearch.com]
Sent: donderdag 26 mei 2011 12:13
To: users@elasticsearch.com
Subject: Re: sorting facets on score

Check the ordering option in terms stats: http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html.

On Thursday, May 26, 2011 at 11:58 AM, Yannick Smits wrote:

Thanks, got it to work with this syntax:

"facets" : {

"tag_book_stats" : {

"terms_stats" : {

"key_field" : "book.name",

"value_script"" : "doc.score"

}

}

}

But it shows me the score and the count now but still sorts on count instead of score.

From: Shay Banon [mailto:shay.banon@elasticsearch.com]
Sent: vrijdag 20 mei 2011 17:00
To: users@elasticsearch.com
Subject: Re: sorting facets on score

You can use terms stats, and provide a value_script with "doc.score".

On Friday, May 20, 2011 at 3:38 PM, Yannick Smits wrote:

Instead of sorting facets by document count is it possible to sort facets by document score?


(dburge) #6

Hello Yannick Smits-2,

I'm having a problem setting the ordering on doc.score. Could you please post the code that finally worked for you ?

Thanks,
Davdi


(system) #7