首页 > 解决方案 > 当我有弹性搜索索引异常时,我可以指定详细信息字段吗?

问题描述

当我尝试索引 elasticsearch 时收到错误消息:得到响应{'took': 1, 'errors': True, 'items': [{'index': {'_index': 'mapstore-development-products', '_type': 'product', '_id': '776896', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'number_format_exception', 'reason': 'empty String'}}}}]}

有什么方法可以让我从这个返回结果中知道哪些特定字段是空的?

标签: elasticsearch

解决方案


此问题是由于 (1) 在发布第一条记录之前未创建索引映射 (2) 您的第一条记录有一个空字段(字符串),稍后您希望它是数字。

如果您没有提前指定映射,Elasticsearch 会为您的字段动态分配类型。我认为您不应该找到特定的空字符串字段。相反,您应该在发布第一条记录之前为您的索引创建映射,以便解决此问题。对于您的情况,您可能需要创建一个具有正确映射的新索引,然后重新索引。

看到这个:

  1. https://discuss.elastic.co/t/how-to-resolve-numberformatexception-issues-caused-by-an-empty-string/5633
  2. https://medium.com/@eyaldahari/reindex-elasticsearch-documents-is-easier-than-ever-103f63d411c

推荐阅读