您好我正在尝试通过python-elastic-search进行putmapping。我想在我的代码中添加大小写密集的映射。请检查映射并帮助我。获得500传输错误not_x_content_exception。
mapping = '''
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"analyzer_keyword": {
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
}
},
"mappings": {
"countrycpm": {
"properties": {
"uid": {
"type": "text"
},
"country": {
"type": "text"
},
"cpm": {
"type": "float"
},
"createdby": {
"type": "text"
},
"updatedby": {
"type": "text"
},
"createddate": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss.SSS"
},
"updateddate": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss.SSS"
},
"status = mode": {
"type": "integer"
},
"createdbyname": {
"type": "text"
},
"updatedbyname": {
"type": "text"
}
}
}
}
}
'''
els.indices.put_mapping(index = ES_INDEX, doc_type = 'countrycpm',body=json.dumps(mapping))
响应
TransportError Traceback (most recent call last)
<ipython-input-57-4c3baa9096ca> in <module>()
----> 1 els.indices.put_mapping(index = ES_INDEX, doc_type = 'countrycpm',body=json.dumps(map))
/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.pyc in _wrapped(*args, **kwargs)
67 if p in kwargs:
68 params[p] = kwargs.pop(p)
---> 69 return func(*args, params=params, **kwargs)
70 return _wrapped
71 return _wrapper
/usr/local/lib/python2.7/dist-packages/elasticsearch/client/indices.pyc in put_mapping(self, doc_type, body, index, params)
289 raise ValueError("Empty value passed for a required argument.")
290 _, data = self.transport.perform_request('PUT', _make_path(index,
--> 291 '_mapping', doc_type), params=params, body=body)
292 return data
293
/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.pyc in perform_request(self, method, url, params, body)
305
306 try:
--> 307 status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
308
309 except TransportError as e:
/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.pyc in perform_request(self, method, url, params, body, timeout, ignore)
91 if not (200 <= response.status < 300) and response.status not in ignore:
92 self.log_request_fail(method, url, body, duration, response.status)
---> 93 self._raise_error(response.status, raw_data)
94
95 self.log_request_success(method, full_url, url, body, response.status,
/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.pyc in _raise_error(self, status_code, raw_data)
103 pass
104
--> 105 raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
106
107
TransportError: TransportError(500, u'not_x_content_exception')
答案 0 :(得分:0)
你无法在索引中更新这样的映射,你需要创建新的映射并将此映射指定为新的变量,否则你必须删除索引并相应地更新它。