elasticsearch Opensearch Jmeter 板中显示的时间戳错误

dgsult0t  于 2023-01-08  发布在  ElasticSearch
关注(0)|答案(2)|浏览(169)

我尝试用Python客户端SDK向我的opensearch示例添加一些文档,如下所示:

import opensearchpy

host = 'my_remote_host.com'
port = 9200
auth = ('admin', 'admin')

client = opensearchpy.OpenSearch(
    hosts=[{'host': host, 'port': port}],
    http_compress=True,
    http_auth=auth,
    use_ssl=False,
    verify_certs=False,

)

index_name = 'loggerheads'

# Add a document to the index.
document = {
  'timestamp': '2022-02-09 11:11:11.111',
  'message': 'some random ship'
}

response = client.index(
    index = index_name,
    body = document,
    refresh = True
)

我以前配置过Map,如下所示:

PUT loggerheads
{
  "mappings": {
    "properties": {
      "timestamp": {
        "type": "date",
        "format": ["YYYY-MM-DD HH:mm:ss.SSS"]
      },
      "message": {
        "type": "text"
      }
    }
  }
}

时间戳显示错误:

我是否做错了什么,或者这是一个bug?

编辑

我向opensearch发送了一系列文档,发现2023年的任何日期都显示为2023-01-02,而且:

  • 2022年-〉一年一月一日
  • 2021年-〉2021-01-04
  • 2020年-〉1个月3个月1个月
  • 2019年-〉1个月4个月1个月
  • 2018年-〉1个月5个月1个月
  • 2017年-〉1个月6个月1个月
  • 2016年-〉1月7日至1月
  • 2015年-〉1个月8个月1个月
  • 2014年-〉1月9日至1月
  • 2013年-〉1个月10年1个月
  • 2012年-〉十一月十一日
  • 2011年-〉1月12日至1月
  • 2010年-〉1月13日至1月
lvjbypge

lvjbypge1#

format中的大小写似乎有问题。请尝试以下操作。

PUT loggerheads
{
  "mappings": {
    "properties": {
      "timestamp": {
        "type": "date",
        "format": ["yyyy-MM-dd HH:mm:ss.SSS"]
      },
      "message": {
        "type": "text"
      }
    }
  }
}

https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html#multiple-date-formats

ig9co6j1

ig9co6j12#

进入堆栈管理-〉高级设置。更改日期格式中的值。x1c 0d1x

相关问题