0

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' }
Headshota
  • 21,021
  • 11
  • 61
  • 82
  • i think there is no such thing for documents. i thought there was a simple get(id) but i can't find it any longer... – phoet Oct 10 '14 at 12:27

1 Answers1

0

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
}
Vamsi Krishna
  • 3,742
  • 4
  • 20
  • 45