Pete Noc
Pete Noc

Reputation: 31

Using field names containing the "@" (@timestamp) in elasticsearch-dsl

I have a feeling that my question must have a trivial answer but several hours of googling and searching python tutorials and I am still stuck.

My Field names often contain the "@" character (i.e @timestamp) and the "@" is used by python for decorator functions.

How do you reference these field names in elasticsearch-dsl? (I am using python 3.6.2)

resp = s.execute()

for hit in resp:
    print(hit.response_code)
    print(hit.@timestamp)

Of course I tried escaping and quoting.

Upvotes: 0

Views: 250

Answers (1)

Honza Král
Honza Král

Reputation: 3022

you can always use hit['@timestamp'] or getattr(hit, '@timestamp')

Upvotes: 1

Related Questions