Check if document key/id exists with Tire

236 views Asked by At

I am using Tire gem as an elasticsearch client.

I wanted to know if there is a way to know if the document with known id exists in the index?

something like:

 Tire.exists? { index: 'myIndex', type: 'myType', id: 'myId' }
1

There are 1 answers

0
Vamsi Krishna On

Please try this,

Tire::Configuration.client.get "#{Tire::Configuration.url}/myindex/mytype/myid?pretty"

If the document exists then returns the document with indexed properties or else the response body contains

{
  "exists" : false
}