Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 714 Bytes

File metadata and controls

26 lines (21 loc) · 714 Bytes
endpoint exists_source
lang python
es_version 9.3
client elasticsearch==9.3.0

Elasticsearch 9.3 exists_source endpoint (Python 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")
    print(f"Source available: {doc['name']}")
else:
    print("No source available")

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.