插入数据时,ElasticSearch Mapper解析异常

时间:2018-08-22 07:19:50

标签: python parsing elasticsearch mapping aws-elasticsearch

https://pastebin.com/Xu9CH4B1

我已经分享了我想通过Mapping在Elasticsearch中插入的上述数据示例:

elastic_search.indices.put_mapping(
                index=index_name_requester,
                doc_type=doc_type_requester,
                body={
                    "properties": {
                        "source_geocode.coordinates": {
                            "type": "geo_point"
                        },
                        "destination_geocode.coordinates": {
                            "type": "geo_point"
                        },
                        "geocodes": {
                            "type": "geo_shape"
                        },
                        "route_box": {
                            "type": "geo_shape"
                        },
                        "start_date_time": {
                            "type": "date",
                            "format": "YYYY-MM-dd'T'HH:mm:ss.SSSSSSZ||yyyy-MM-dd||epoch_millis"
                        }
                    }
                }
            )

弹性搜索版本: 6.3.2

预期行为: 成功插入

当前错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in insertion
  File "/home/shobhit/.local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/shobhit/.local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 319, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File "/home/shobhit/.local/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 "/home/shobhit/.local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 186, in perform_request
    self._raise_error(response.status, raw_data)
  File "/home/shobhit/.local/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')

但是有一个类似的数据,其值的更改已插入,我共享了一个指向以下数据的链接:

https://pastebin.com/4cQzQQ0M

请帮助确定数据出了什么问题。谢谢!

1 个答案:

答案 0 :(得分:0)

我找到了问题的根源。这是lat-long的问题,在两种情况下lat-long的格式都是错误的,但其中1个插入错误,而另外1个则没有。

以下日志中提到的行提到了正确的问题:

Caused by: java.lang.IllegalArgumentException: illegal latitude value [144.62810199999998] for source_geocode.coordinates

谢谢!