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

时间:2015-10-14 14:33:12

标签: python elasticsearch

我正在尝试与映射一起创建一个新索引(elasticsearch 2.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

Traceback (most recent call last):
  File "C:/dev/Scans/L_build_vulns_index.py", line 38, in <module>
    elasticsearch.client.IndicesClient(client=es).create(index=vulns_index, body=mapping)
  File "C:\Python34\lib\site-packages\elasticsearch\client\utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "C:\Python34\lib\site-packages\elasticsearch\client\indices.py", line 102, in create
    params=params, body=body)
  File "C:\Python34\lib\site-packages\elasticsearch\transport.py", line 307, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "C:\Python34\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 89, in perform_request
    self._raise_error(response.status, raw_data)
  File "C:\Python34\lib\site-packages\elasticsearch\connection\base.py", line 105, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'mapper_parsing_exception')

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

注意:这个脚本过去曾经用过,我能想到的唯一令人难忘的变化是弹性搜索的升级

1 个答案:

答案 0 :(得分:1)

请注意,2.0 _timestamp字段has been deprecated

但主要问题是path属性为no longer available(+ here)。