Elasticsearch范围请求

时间:2015-06-15 11:57:44

标签: php curl elasticsearch range

我想创建一个请求,将最后15分钟的所有文件发送给我。 我的XPUT文档如下所示:

curl -XPUT localhost:9200/indexname/documentname/4 -d'
{
    "user": "sergey",
    "onlineUserCount": "43"
}'

我这样搜索过:

$ curl -XGET localhost:9200/indexname/documentname/_query -d'{
"query":{
  "range":{
    "timestamp":{
      "gt": "now -15m"
    }
  }
}}'

但它给了我

{"_index":"indexname","_type":"documentname","_id":"_query","found":false}

请帮助!!!

1 个答案:

答案 0 :(得分:0)

您需要使用_search端点而不是_query端点,在HTTP请求正文中发送查询时,建议使用-XPOST。

$ curl -XPOST localhost:9200/indexname/documentname/_search -d'{
"query":{
  "range":{
    "timestamp":{
      "gt": "now -15m"
    }
  }
}}'