Search code examples
python-3.xelasticsearch-dsl

Cannot access elasticsearch_dsl meta.id


I want to use meta ID field to add a new index/field based on the searched data, but I cannot access meta.id field. What should I do? Here is the code below -

from elasticsearch import Elasticsearch  
from elasticsearch_dsl import Search  

es = Elasticsearch(Host="http://localhost", PORT=9200)  

request = Search(using=es, index='internal', doc_type="doc")  

response = request.scan()  

for each in response:  
....alert = each.to_dict()  
....print(alert["id"])  

Solution

  • What do you mean by cannot access? What happens if you do each.meta.id in your for loop?