user3024742
user3024742

Reputation: 63

Get @timestamp value in elasticsearch response

I'm using elasticsearch-dsl-py to extract data from elasticsearch.

I want to save the value of the @timestamp field (hits.hits._source.@timestamp). But I have no clue how to deal with the fact that the @ character is not allowed in Python.

How do I get the value from @timestamp? This does not work:

h = response.hits[0]
print(h.@timestamp)

Thanks

Upvotes: 1

Views: 1039

Answers (1)

moliware
moliware

Reputation: 10278

In that case you can access that field as follows:

h = response.hits[0]
print h['@timestamp']

Upvotes: 2

Related Questions