python elasticsearch get field from given doc_id

199 Views Asked by At

My input is <index_name>, <doc_id>, <field_name>, i want the value of the field

I am looking for python-client equivalent of

GET <index_name>/_doc/<doc_id>/?_source_includes=<field_name>
1

There are 1 best solutions below

0
Kaushik J On

I figured it out

from elasticsearch import Elasticsearch
es = Elasticsearch()
result = es.get(
             index=<index_name>,
             id=<doc_id>,
             _source_includes=<field_name>
         )