liuhuanyong/MusicLyricChatbot

elasticsearch.exceptions.RequestError

Opened this issue · 3 comments

大神你好!
我把Elasticsearch下好了,服务挂起来了,但是运行python insert_es.py时发生了如下错误:
Traceback (most recent call last): File "insert_es.py", line 161, in <module> init_ES() File "insert_es.py", line 111, in init_ES pie.create_mapping() File "insert_es.py", line 72, in create_mapping self.es.indices.create(index=self._index, body=node_mappings) File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped return func(*args, params=params, **kwargs) File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/client/indices.py", line 105, in create "PUT", _make_path(index), params=params, body=body File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/transport.py", line 353, in perform_request timeout=timeout, File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 251, in perform_request self._raise_error(response.status, raw_data) File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/base.py", line 178, in _raise_error status_code, error_message, additional_info elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'Root mapping definition has unsupported parameters: [music : {properties={song={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, geci={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, singer={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, album={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, composer={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, author={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}}}]')

我上网查到 How to fix ElasticSearch ‘Root mapping definition has unsupported parameters’,说是json格式不对。既然大神已经跑通过,数据格式肯定是没问题的,所以来问问大神这个错误应该从哪里入手。

大神你好!
我把Elasticsearch下好了,服务挂起来了,但是运行python insert_es.py时发生了如下错误:
Traceback (most recent call last): File "insert_es.py", line 161, in <module> init_ES() File "insert_es.py", line 111, in init_ES pie.create_mapping() File "insert_es.py", line 72, in create_mapping self.es.indices.create(index=self._index, body=node_mappings) File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped return func(*args, params=params, **kwargs) File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/client/indices.py", line 105, in create "PUT", _make_path(index), params=params, body=body File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/transport.py", line 353, in perform_request timeout=timeout, File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 251, in perform_request self._raise_error(response.status, raw_data) File "/Users/wuhaixu/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/base.py", line 178, in _raise_error status_code, error_message, additional_info elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'Root mapping definition has unsupported parameters: [music : {properties={song={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, geci={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, singer={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, album={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, composer={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}, author={search_analyzer=ik_smart, analyzer=ik_max_word, index=true, type=text}}}]')

我上网查到 How to fix ElasticSearch ‘Root mapping definition has unsupported parameters’,说是json格式不对。既然大神已经跑通过,数据格式肯定是没问题的,所以来问问大神这个错误应该从哪里入手。

大哥,您好,可能是ik分词需要配置一下。

能否指明调试时用的哪个elasticsearch版本?
用elasticsearch 7.7.1版本会出现mapping问题,是因为7.7版本移除了mapping
用elasticsearch 6.8.10版本会出另外一个错误:
insert_es.py:71: ElasticsearchDeprecationWarning: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
self.es.indices.create(index=self._index, body=node_mappings)
insert_es.py:71: ElasticsearchDeprecationWarning: [types removal] The parameter include_type_name should be explicitly specified in create index requests to prepare for 7.0. In 7.0 include_type_name will default to 'false', and requests are expected to omit the type name in mapping definitions.
self.es.indices.create(index=self._index, body=node_mappings)
Traceback (most recent call last):
File "insert_es.py", line 158, in
init_ES()
File "insert_es.py", line 108, in init_ES
pie.create_mapping()
File "insert_es.py", line 71, in create_mapping
self.es.indices.create(index=self._index, body=node_mappings)
File "C:\Python27-64\lib\site-packages\elasticsearch\client\utils.py", line 92, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
File "C:\Python27-64\lib\site-packages\elasticsearch\client\indices.py", line 103, in create
"PUT", _make_path(index), params=params, headers=headers, body=body
File "C:\Python27-64\lib\site-packages\elasticsearch\transport.py", line 362, in perform_request
timeout=timeout,
File "C:\Python27-64\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 252, in perform_request
self._raise_error(response.status, raw_data)
File "C:\Python27-64\lib\site-packages\elasticsearch\connection\base.py", line 282, in _raise_error
status_code, error_message, additional_info
elasticsearch.exceptions.RequestError: RequestError(400, u'mapper_parsing_exception', u'analyzer [ik_smart] not found for field [song]')

最后解决了,安装6.8.10 ES
然后安装IK 插件。然后需要重启下服务和python
不过json数据里有大概20个IK识别不了的歌曲数据,包含album和歌词。最简单的就是删除了就好了。