首页 > 解决方案 > Elasticsearch:使用特殊领域作为模板的PK改进研究

问题描述

以下是 ElasticSearch 中的一个模板,我的问题是,是否有办法推广其中一个字段,例如timeStamp,作为主键来帮助查询期间的研究;就像它通常发生在数据库上一样。

  {
  "order": 0,
  "template": "simsamples-*",
  "settings": {
    "index": {
      "number_of_shards": "1"
    }
  },
  "mappings": {
    "ProbeSamples": {
      "properties": {
        "date": {
          "index": "no",
          "type": "string"
        },
        "timeStamp": {
          "format": "epoch_second",
          "type": "date"
        },
        "temperatures": {
          "type": "double"
        },
        "id": {
          "index": "not_analyzed",
          "type": "string"
        }
      }
    }
  }
}

标签: amazon-web-servicesperformancetemplateselasticsearch

解决方案


elasticsearch中没有主键。每个文档都自动有一个_id字段,这是一种主键,因为它是一个唯一标识符。

Elasticsearch 正在为每个字段创建索引,因此无需指定一个作为主键。


推荐阅读