| endpoint | exists_source |
|---|---|
| lang | python |
| 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")
print(f"Source available: {doc['name']}")
else:
print("No source available")This is primarily useful when working with indices where _source may
be disabled in the mapping. For most indices, client.exists() is
sufficient.