弹性搜索的每日新索引

时间:2019-05-02 08:07:21

标签: c# elasticsearch asp.net-core-webapi

我在Elastic处有一个time_series索引。

PUT time_series
{
  "settings": {
    "number_of_shards": 3
  },
  "mappings": {
    "timeseries": {
      "properties": {
                "timestamp" : { 
                  "type" : "date",
                  "format": "MM/dd/yyyy HH:mm:ss"
                  },
                "value" : { "type" : "double" },
                "recordid" : { "type" : "integer" }
      }
    }
  }
}

从C#中,我向索引提供数据。 我想每天有一个新索引 像

  • time_series_19050 2
  • time_series_19050 3
  • ...

到目前为止,我了解我需要设置一个模板。 我试过了,但状态= 400。

PUT _template/template_1
{
  "index_patterns": ["time_series*"],
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "timeseries": {
      "enabled": false
    },
    "properties": {
      "host_name": {
        "type": "keyword"
      },
      "created_at": {
        "type": "date",
        "format": "_yyyyMMDD"
      }
    }
  }
}

如何每天获取新索引?

我是否需要使用当前日期调整C#代码的索引,或者它会自动纳入每日索引?

1 个答案:

答案 0 :(得分:0)

我遇到了几乎相同的问题。我所做的是创建一个控制台项目(因为我还有其他操作要做),每次= 00:01:00都创建一个新索引。 (控制台项目每5分钟触发一次)。 看到此链接,可能会帮助您https://discuss.elastic.co/t/elasticsearch-for-logging-how-to-configure-automatic-creation-of-the-new-index-every-day/19467/3

相关问题