gpt4 book ai didi

spring - 如何在Elasticsearch中获取时间戳值?

转载 作者:行者123 更新时间:2023-12-03 02:03:06 26 4
gpt4 key购买 nike

如何获取时间戳值?我已经将enable和store设置为true,我可以在Sense上看到它,但无法获取它。

  {
"cubx": {
"mappings": {
"organization": {
"_timestamp": {
"enabled": true,
"store": true
},
"properties": {
"address": {
.
.
.

我能看到它...
GET /abc/organization/1234?fields=_timestamp

{
"_index": "abc",
"_type": "organization",
"_id": "1234",
"_version": 1,
"found": true,
"fields": {
"_timestamp": 1430535032967
}
}

但是我找不到它...
public GetField getTimestamp(Long companyId) {

GetResponse response = client
.prepareGet(index, type, companyId.toString()).execute()
.actionGet();

return response.getField("_timestamp");

它返回空值。我已经在这里阅读了很多文章,但是没有找到示例来获取对象的值。我也尝试按照 post的建议使用script_value,但没有成功。

有人可以帮我弄清楚我在做什么错吗?

最佳答案

您需要像GetResponse response = client .prepareGet(index, type, companyId.toString()).setFields("_timestamp").execute() .actionGet();这样使用它。

关于spring - 如何在Elasticsearch中获取时间戳值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29998531/

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