Using the debug console, I've arrived at the "result" i want. I achieved it using:
response.hits.hits[0]._source
So i took it one step further and decided to create a loop:
projection = []
for hit in response.hits:
for subHit in hit.hits:
projection.append(subHit._source)
but now i'm getting a exeception stating that subHit does not have hits property... and I'm confused...
What am I doing wrong?
asked Jul 24, 2019 at 14:49
Leonardo
11.5k14 gold badges78 silver badges189 bronze badges
1 Answer 1
Looks like your response.hits is not an array but response.hits.hits is an array. So you must be just doing like,
for hit in response.hits.hits:
projection.append(hit._source)
answered Jul 24, 2019 at 14:52
Praveenkumar
2,1921 gold badge11 silver badges19 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
for hit in response.hits.hits