23134


elasticsearchを使っているのですが、APIで値を取得する方法が分からず困っているため、ご教示頂ければ幸いです。

下図のようなデータが1分毎に入ってきているのですが、最新の情報を取得する方法を教えて頂けないでしょうか？  
[![画像の説明をここに入力](https://i.stack.imgur.com/69cL1.jpg)](https://i.stack.imgur.com/69cL1.jpg)

例  
17時32分時点（最新時点）での[status.200] の合計値。

[code]

    curl -XGET 'http://10.1.37.29:9200/ssp_nginx/_search?pretty' -d '
    > {
    >   "fields": [ "status.200"]
    > }'
    
[/code]

このクエリで最新の[status.200]が取得されるものかと思ったのですが、見てお分かりになられますように違っております。

[code]

    {
      "took" : 33,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "failed" : 0
      },
      "hits" : {
        "total" : 2484888,
        "max_score" : 1.0,
        "hits" : [ {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBW3z7QeAQK4eWjC",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 3062 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBXOq_jM0m5v7D3L",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 496 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBXOq_jM0m5v7D3S",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 34 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBXOq_jM0m5v7D3V",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 17251 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBXOq_jM0m5v7D3W",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 2 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBXOq_jM0m5v7D3Z",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 1139 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBZtq_jM0m5v7D3i",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 15 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBZtq_jM0m5v7D3l",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 1085 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBZtq_jM0m5v7D3o",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 86 ]
          }
        }, {
          "_index" : "ssp_nginx",
          "_type" : "report",
          "_id" : "AVMkyBZtq_jM0m5v7D3p",
          "_score" : 1.0,
          "fields" : {
            "status.200" : [ 36 ]
          }
        } ]
      }
    }
    
[/code]


CC BY-SA 3.0
2016-03-14T09:22:22.693
23117
2016-03-15T23:06:13.250
2016-03-15T23:06:13.250
8000
14384
question
elasticsearch
elasticsearchで最新の情報をAPIで取得する方法について。


[_timestamp](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-
timestamp-field.html)が有効になっていれば、ソートすればよいでしょう。

[code]

    curl -XGET 'http://10.1.37.29:9200/ssp_nginx/_search?pretty' -d '
    {
      "fields": [ "status.200"],
      "sort": [
        {
          "_timestamp": { 
            "order": "desc"
          }
        }
      ]
    }
    
[/code]


CC BY-SA 3.0
2016-03-14T16:51:16.270
23134
2016-03-14T16:51:16.270
7837
23117
answer