| endpoint | exists_source |
|---|---|
| lang | ruby |
| es_version | 9.3 |
| client | elasticsearch==9.3.0 |
Use client.exists_source to check whether a document's _source
field exists. Returns false if the document does not exist or if
_source is disabled for the index.
if client.exists_source(index: 'products', id: 'prod-1')
doc = client.get_source(index: 'products', id: 'prod-1')
puts "Source available: #{doc['name']}"
else
puts 'No source available'
endThis is primarily useful when working with indices where _source may
be disabled in the mapping. For most indices, client.exists is
sufficient.