简体   繁体   English

Elasticsearch范围请求

[英]Elasticsearch range request

I want to create a request that transmits me all the documents for last 15min. 我想创建一个请求,将最近15分钟的所有文档传送给我。 My XPUT document looks like this: 我的XPUT文档如下所示:

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

I've searched like this: 我这样搜索:

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

But It gave me 但这给了我

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

Help please!!! 请帮助!!!

You need to use the _search endpoint instead of the _query endpoint and it's more advisable to use -XPOST when sending a query in the HTTP request body. 您需要使用_search端点而不是_query端点,并且在HTTP请求正文中发送查询时,更建议使用-XPOST。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM