如何获取 Elasticsearch 中的时间戳值?
How can I get the timestamp value in Elasticsearch?
如何获取时间戳值?我已经将 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");
它returns 无效。我已经在这里阅读了很多帖子,但没有找到获取对象值的示例。我也尝试按照 post 中的建议使用 script_value 但没有成功。
谁能帮我弄清楚我做错了什么?
您需要像这样使用它 GetResponse response = client .prepareGet(index, type, companyId.toString()).setFields("_timestamp").execute() .actionGet();
。
如何获取时间戳值?我已经将 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");
它returns 无效。我已经在这里阅读了很多帖子,但没有找到获取对象值的示例。我也尝试按照 post 中的建议使用 script_value 但没有成功。
谁能帮我弄清楚我做错了什么?
您需要像这样使用它 GetResponse response = client .prepareGet(index, type, companyId.toString()).setFields("_timestamp").execute() .actionGet();
。