Headshota
Headshota

Reputation: 21449

Check if document key/id exists with Tire

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' }

Upvotes: 0

Views: 237

Answers (1)

Vamsi Krishna
Vamsi Krishna

Reputation: 3792

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
}

Upvotes: 0

Related Questions