【问题标题】:Getting indexes with timestamp but adding custom hours/minutes/ in elasticsearch Python获取带有时间戳的索引,但在 elasticsearch Python 中添加自定义小时/分钟/
【发布时间】:2021-11-16 00:28:33
【问题描述】:

我一直在尝试使用这种类型的查询接收从 7 天前到现在的所有索引:

        query = {'query': {
                        'bool': {
                            'filter': [ 
                                {'range': {'@timestamp':{'gte': now-7d/d,'lte': now/d}}},
                                ]
                            }
                        }
                       }

问题是我需要从上午 12 点(午夜)到晚上 11:59 获取它们。注意:日期时间“现在”不能硬编码;它需要有确切的日期,即脚本运行的时间。是否可以在不使用 datetime 的情况下仅依赖 Python 的 elasticsearch api 中内置的“数据数学”来做到这一点?

编辑:澄清一下,我需要设置确切的时间以提供准确的时间间隔。示例:获取时间戳在上午 11:30 到 12:00 之间的数据,以此类推(间隔 30 分钟)。

【问题讨论】:

    标签: python elasticsearch


    【解决方案1】:
    猜你喜欢
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多