0

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?

2
  • 1
    for hit in response.hits.hits Commented Jul 24, 2019 at 14:51
  • The second hits isn't a property, but it is an object Commented Jul 24, 2019 at 14:52

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.