Skip to content Skip to sidebar Skip to footer

How To Access The Response Object Using Elasticsearch Dsl For Python

I have the following code: s = Search(using=Elasticsearch('http://user:passwd@ipaddress'), index='myindex') q = Q('multi_match', query='some query', fields=['_all']) s = s.query(q)

Solution 1:

For the "toDict" question, response.to_dict() works for me. Not sure if this behaviour is the same across lib versions.

Solution 2:

Apparently the ".title" references an actual column in their example. When I used hit.doc.FIRSTTAG, FIRSTTAG being a column in MY NoSQL-db it worked. Still does not explain the missing method, but I am happy with it for now.

So to anyone having the same problem:

Use your own columns names when evaluating the response object e.g. in my example:

for hit in response:
  print(hit.doc.FIRSTTAG)

Post a Comment for "How To Access The Response Object Using Elasticsearch Dsl For Python"