elasticsearch 大于2^63-1的动态映射数字字段数据类型(长类型),elasticsearch,mapping,long-integer,elasticsearch,Mapping,Long Integer" /> elasticsearch 大于2^63-1的动态映射数字字段数据类型(长类型),elasticsearch,mapping,long-integer,elasticsearch,Mapping,Long Integer" />

elasticsearch 大于2^63-1的动态映射数字字段数据类型(长类型)

elasticsearch 大于2^63-1的动态映射数字字段数据类型(长类型),elasticsearch,mapping,long-integer,elasticsearch,Mapping,Long Integer,我有下面的示例输入数据“doc” 使用python elasticsearch编制索引: doc = { "node": [{ "table": [{ "node-table": { "packets-up": 18440044073709951615, "packets-down": 18447644073709991615 } }] }] } fro

我有下面的示例输入数据“doc”

使用python elasticsearch编制索引:

doc =  {
    "node": [{
        "table": [{
          "node-table": {
            "packets-up": 18440044073709951615,
            "packets-down": 18447644073709991615
          }
        }]
      }]
}

from elasticsearch import Elasticsearch

es = Elasticsearch(hosts="localhost:9200")

res = es.indices.create(index="doc")

es.index(index="doc", doc_type='docs', body=doc)
尝试使用动态映射对数据进行索引时,出现以下错误:

    Traceback (most recent call last):
  File "test.py", line 60, in <module>
    es.index(index="doc_test", doc_type='docs', body=doc)
  File "/Users/user/Projects/2018/es_test/.env/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Users/user/Projects/2018/es_test/.env/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 319, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File "/Users/user/Projects/2018/es_test/.env/lib/python2.7/site-packages/elasticsearch/transport.py", line 318, in perform_request
    status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
  File "/Users/user/Projects/2018/es_test/.env/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 186, in perform_request
    self._raise_error(response.status, raw_data)
  File "/Users/user/Projects/2018/es_test/.env/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: RequestError(400, u'mapper_parsing_exception', u'failed to parse')
答复:

    {
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "illegal_state_exception",
      "reason" : "No matching token for number_type [BIG_INTEGER]"
    }
  },
  "status" : 400
}

你有两个选择来避免这个问题

选项A。将这些值存储为浮点值(或双精度值),而不是长值

首先,您需要确保您的
数据包向下
数据包向上
字段映射为
浮点
(或
双精度
),如下所示:

PUT doc_test
{
  "mappings": {
    "docs": {
      "dynamic_templates": [
        {
          "bignums": {
            "match": "packets*",
            "mapping": {
              "type": "float"
            }
          }
        }
      ]
    }
  }
}
然后需要将数字用双引号括起来,并将其作为字符串发送:

doc =  {
    "node": [{
        "table": [{
          "node-table": {
            "packets-up": "18440044073709951615",
            "packets-down": "18447644073709991615"
          }
        }]
      }]
}
doc =  {
    "node": [{
        "table": [{
          "node-table": {
            "packets-up": "18440044073709951615",
            "packets-down": "18447644073709991615"
          }
        }]
      }]
}
这将起作用,您将能够将数据包字段与包含数值的任何其他字段相加

选项B.启用(默认情况下禁用)

然后还需要将数字用双引号括起来,并将其作为字符串发送:

doc =  {
    "node": [{
        "table": [{
          "node-table": {
            "packets-up": "18440044073709951615",
            "packets-down": "18447644073709991615"
          }
        }]
      }]
}
doc =  {
    "node": [{
        "table": [{
          "node-table": {
            "packets-up": "18440044073709951615",
            "packets-down": "18447644073709991615"
          }
        }]
      }]
}

因此,大数字将映射为
float

您能显示ES日志中的错误吗?ES日志中没有任何错误:elastic |[2018-11-28T08:43:25472][INFO][o.e.l.LicenseService][BbQVxzK]许可证[4ac5ba24-82a8-4d66-8bb9-13272ca43a45]模式[basic]-有效的elastic 2018-11-28T08:43:25496][INFO][o.e.g.GatewayService][BbQVxzK]将[3]索引恢复到集群状态elastic][2018-11-28008:43:26313][INFO][o.e.c.r.a.AllocationService][BbQVxzK]集群健康状态从[红色]更改为[绿色](原因:[碎片开始[[doc 0]]…])。您能否启用
elasticsearch trace
日志记录,以便查看发送的内容()?@Val更新了错误回溯。您应该将其添加到您的问题中(更清晰)。另外,请添加您当前的映射,即从
curl-XGET localhost:9200/doc\u test/\u mapping/docs
中获得的内容。不管怎样,我需要用引号修改数字输入吗?