elasticsearch 如何确定指数的时间域?

nue99wik  于 2022-11-02  发布在  ElasticSearch
关注(0)|答案(2)|浏览(129)

是否有es查询或某种方式来询问Elasticsearch哪个字段被用作特定索引的时间字段?

qpgpyjmq

qpgpyjmq1#

您可以使用Kibana来选择正确的时间字段(步骤5):

1.在Kibana中,开启[管理],然后按一下[索引模式]。
1.如果这是您的第一个索引样式,“建立索引样式”页面会自动开启。否则,请按一下左上角的建立索引样式。
1.在“索引模式”字段中输入“your_index_name*”。
1.单击下一步
1.在“配置设置”中,从“时间过滤器”字段名称下拉菜单中选择“@your_timestamp_field”。
1.单击创建索引模式。
Kibana使用者指南:Defining your index patterns

或在索引Map中搜索“type:日期”

curl 'http://localhost:9200/your_index/_mapping?pretty'
{
  "your_index" : {
    "mappings" : {
      "your_index" : {
        "properties" : {
          "@**timestamp**" : {
            "type" : "date"
          },
          "@version" : {
            "type" : "text"
          },
          "clock" : {
            "type" : "long"
          },
          "host" : {
            "type" : "text"
          },
          "type" : {
            "type" : "text"
          }
        }
      }
    }
  }
}

Get Mapping

或查看已编制索引的文档:

curl 'http://localhost:9200/your_index/_search?pretty'
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "your_index",
        "_type" : "your_index",
        "_id" : "logstash-01.kvm.local",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2018-11-10T18:03:22.822Z",
          "host" : "logstash-01.kvm.local",
          "@version" : "1",
          "clock" : 558753,
          "type" : "your_index"
        }
      }
    ]
  }
}

Search API

e5nqia27

e5nqia272#

如果您已经创建了索引,并且想要检查哪个字段用作时间字段,请向下导航到“管理”/“堆栈管理”/“索引模式”,选择您的索引并搜索字段。用作时间字段的字段旁边有时间(时钟)图标。

相关问题