What is the most efficient way oof testing if a document with an _id exists?
I could obviously do:
curl -XGET localhost:9200/my_index/my_doctype/<_id>?fields=_id'.
Or I could go with: How do I check for duplicate data on ElasticSearch? and send an empty document, I guess.
Anything more efficient?
You can use the HTTP HEAD verb to retrieve the headers only.
curl -XHEAD --dump-header - localhost:9200/index/type/doc
It will provide you with either 200 or 404 without any part of the document body.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With