简体   繁体   中英

Elasticsearch range request

I want to create a request that transmits me all the documents for last 15min. My XPUT document looks like this:

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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