【问题标题】:Get @timestamp value in elasticsearch response在弹性搜索响应中获取@timestamp 值
【发布时间】:2016-02-06 12:11:56
【问题描述】:

我正在使用elasticsearch-dsl-pyelasticsearch 中提取数据。

我想保存 @timestamp 字段 (hits.hits._source.@timestamp) 的值。但我不知道如何处理 Python 中不允许使用 @ 字符这一事实。

如何从@timestamp 获取值?这不起作用:

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

谢谢

【问题讨论】:

    标签: python elasticsearch elasticsearch-dsl elasticsearch-dsl-py


    【解决方案1】:

    在这种情况下,您可以按如下方式访问该字段:

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

    【讨论】:

    • 非常感谢这个简单的解决方案。它有效,正是我所需要的。
    猜你喜欢
    • 2021-06-24
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-28
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多