Hi,

The score is not a field of a document but is computed dynamically, you
need to use a script to get it. So replacing `{ "field" : "_score" }` with
`{ "script" : "_doc.score" }` should have the desired effect.


On Fri, Feb 7, 2014 at 2:57 AM, Toan V Luu <luuvinht...@gmail.com> wrote:

> Hi all,
>
> Have you ever tried to order the bucket by field _score of documents
> given a query?
>
> I took example from http://blog.qbox.io/elasticsearch-aggregations and
> make the query:
> curl -XPOST "http://localhost:9200/sports/athlete/_search"; -d '{
>     "query" : {
>             "match" : { "sport" : "baseball" }
>         },
>
>    "size": 0,
>    "aggs": {
>       "sport": {
>          "terms": {
>             "field": "sport",
>             "size": 5,
>             "order" : { "max_score" : "desc" }
>          },
>          "aggs" : {
>              "max_score" : { "max" : { "field" : "_score" } }
>          }
>       }
>    }
> }'
>
> However in the response i see:
>
>     "aggregations": {
>         "sport": {
>             "buckets": [{
>                 "key": "baseball",
>                 "doc_count": 16,
>                 "max_score": {
>                     "value": null
>                 }
>             }]
>         }
>     }
> I know that the 1st document in result list has score 2.098612 for that
> query so why max_score is null in aggregations?
>
> Thanks for your help.
> Toan.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/CAPUM1c21LCuLaveBXS38kd3fSmw-PENKgSqu9z3fQmd5L2C6JQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Adrien Grand

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5nZoO5L81LJq5MKsTSynZaSZCsv68oPGvAg3GA6_8%2B3g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to