gpt4 book ai didi

scala - 如何使elastic4s存储_timestamp字段?

转载 作者:行者123 更新时间:2023-12-02 22:32:50 25 4
gpt4 key购买 nike

我可以在这样的映射上启用时间戳:

"someType" as (
"someField" typed StringType
) timestamp true

但是,要在使用 "fields": ["_timestamp"]搜索时能够检索它,还需要将 store属性设置为 true。但是,如果我这样做:
"someType" as (
"someField" typed StringType,
"_timestamp" typed LongType/DateType store true
) timestamp true

然后 _search不返回它:
GET /myIndex/someType/_search 
{
"fields": ["_timestamp"],
"query" : {
"match_all" : {}
}
}

生成的映射如下所示:
"someType": {
"dynamic": "dynamic",
"_timestamp": {
"enabled": true
},
"properties": {
"_timestamp": {
"store": "yes",
"type": "long"
}
}

}

但是我感觉应该是这样的:
"someType": {
"dynamic": "dynamic",
"_timestamp": {
"enabled": true,
"store": true
},
"properties": {
"_timestamp": {
"store": "yes",
"type": "long"
}
}
}

这不能使用 elastic4s Dsl来完成,因为它没有对名为 _timestamp的字段进行特殊处理,因此该字段转到属性而不是该映射中的字段...

最佳答案

Elastic4s版本1.5.7允许您像这样设置时间戳:

create index("myindex") mappings(
mapping name "foo" timestamp {
timestamp enabled true format "qwerty" store true path "somepath"
}
)

路径,格式和存储是可选的。

关于scala - 如何使elastic4s存储_timestamp字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29947571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com