Scroll api and some parsing issues. (Python)

Hello,

I am trying to print out all the values listed of

  • max_score
    and

  • mobile:

  • home

From this JSON that came from elasticSearches scroll api.

```
{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 1.0,
    "hits": [
      {
        "_index": "contacts",
        "_type": "index",
        "_id": "2",
        "_score": 1.0,
        "_source": {
          "id": "c201",
          "name": "Johnny Depp",
          "phone": {
            "mobile": "+91 0000000000",
            "home": "00 000000"
          }
        }
      }
    ]
  }
}
```

my python code to print out

for hits in res:
  #print hits
    print(hits["max_score"])
    print(hits["_source"][phone]["mobile"])
    print(hits["_source"][phone]["home"])

but I seem to be having an issue getting the data from

  • mobile
  • home.

Any recommendations? I am using python

This has also been posted here.

https://stackoverflow.com/questions/56014461/scroll-api-and-some-parsing-issues-python

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.