创建索引时传递映射的正确格式是什么?

2024-06-01 00:27:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建一个新的索引(elasticsearch2.0.0-beta2)以及映射。在

我正在传递(或者传递给pyelasticsearchelasticsearch.client)以下映射(这是dict的json.dumps):

{
  "mappings": {
    "vulnerability": {
      "_timestamp": {
        "enabled": true,
        "path": "HOST_START_iso"
      },
      "properties": {
        "scan_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "severity": {
          "type": "string",
          "index": "not_analyzed"
        },
        "HOST_START_iso": {
          "format": "epoch_millis||dateOptionalTime",
          "type": "date"
        }
      }
    }
  }
}

索引的创建失败,并出现TransportError(400, 'mapper_parsing_exception')(下面是elasticsearch.client的回溯,上面的映射在mapping中)

^{pr2}$

我从另一个索引得到这个映射,但我不明白这个结构有什么问题(我还试图删除最外层的mappings,结果是创建了索引,但没有任何映射)。在

注意:这个脚本在过去是有用的,我能想到的唯一令人难忘的变化是elasticsearch的升级


Tags: clientjsonhoststringindextypenotiso