- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对Painless非常陌生。我想编写一个简单的脚本来获取@timestamp和T1之间的时差(以毫秒为单位)。
我已经尝试使用doc ['somefield']。value和doc ['somefield']。date.millis,但是我可以访问 @timestamp ,但不能访问 T1 。
任何帮助将不胜感激!我在下面发布了示例数据源:
{
"_source": {
"@timestamp": "2018-11-06T00:20:08.802Z",
"fields": {
"T1": "2018-11-06T00:20:07.862Z",
}
}
最佳答案
您可以创建一个脚本字段,以返回@timestamp
和fields.T1
之间的差异,如下所示:
POST your-index/_search
{
"script_fields": {
"diff": {
"script": {
"source": """
def ts = Instant.parse(params._source['@timestamp']);
def t1 = Instant.parse(params._source.fields.T1);
return ChronoUnit.MICROS.between(ts, t1);
"""
}
}
}
}
关于elasticsearch - 无痛:获得时差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53178425/
我对Painless非常陌生。我想编写一个简单的脚本来获取@timestamp和T1之间的时差(以毫秒为单位)。 我已经尝试使用doc ['somefield']。value和doc ['somefi
场景:在ElasticSearch上有一个文档A,我想在此文档上连接文档B上存在的某些字段。 文件A: { "id": 121423, "name": "Sample Name",
我正在将 Elasticsearch 脚本从 Groovy 转换为 Painless。 该脚本接受一个参数,该参数可以是整数或可转换为整数的字符串(即可以是 123 或 "123" )。 在 Groo
美丽的人的生活方式 一个组件BEAUTIFUL正在使用她的内部akka.actor.Actor做某些事情..(例如“表演”) 还有其他MAN真正想与 BEAUTIFUL“交互”的组件 当BEAUTIF
我正在尝试在Kibana中创建一个脚本化字段,该字段检查“Direction”字段是否为“I”。 if (doc['Direction'].value != "I") {return 1;} else
我在 flex 搜索中对以下文档进行PUT编码: { "_rootId": "327d3aba-4f7c-4abb-9ff3-b1608c354c7c", "_docId": "ID_
我尝试对包含自定义脚本函数的 ElasticSearch (6.4.0) API 执行搜索请求。在这个函数中,我尝试访问一个数组,它应该是响应数据的一部分。但我总是得到一个“null_pointer_
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
我正在使用 painless使用 Elastic 5.5 过滤文档 问题 使用“painless”,查找带有 strings 的文档 field 。 预期成绩 仅带有 strings 的文档字段被返回
我一直在研究聚合,以及使用 painless 编写脚本,但我无法弄清楚如何对对象中的所有值进行迭代/求和。 例子: 我的映射看起来像 "field1": { "properties": {
就像主题一样,我有 Redmine 的工作实例,我只能关闭很短的时间,我如何将我的项目等从 PostgreSQL 迁移到 MySQL 后端? 最佳答案 https://github.com/adamw
我正在运行 Elasticsearch 的本地实例,并尝试在 scripted_fields 下使用“painless”。我可以编写一行脚本代码就好了,但是当我使用三重引号(根据文档支持)来创建多行脚
我是一名优秀的程序员,十分优秀!