Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 700 Bytes

File metadata and controls

27 lines (22 loc) · 700 Bytes
endpoint exists_source
lang ruby
es_version 9.3
client elasticsearch==9.3.0

Elasticsearch 9.3 exists_source endpoint (Ruby example)

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

When to use this

This is primarily useful when working with indices where _source may be disabled in the mapping. For most indices, client.exists is sufficient.