在今天之前,Elasticsearch工作得很好。
问题:
有些文档无法用错误进行索引:
u'Limit of total fields [1000] in index [mintegral_incent] has been exceeded' 错误:
"BulkIndexError: (u'14 document(s) failed to index.', [{u'index': {u'status': 400, u'_type': u'mintegral_incent', u'_id': u'168108082', u'error': {u'reason': u'Limit of total fields [1000] in index [mintegral_incent] has been exceeded', u'type': u'illegal_argument_exception'}使用Amazon弹性服务
Elasticsearch版本5.1
ES设置:
from elasticsearch import Elasticsearch
from elasticsearch import helpers
es_repo = Elasticsearch(hosts=[settings.ES_INDEX_URL],
verify_certs=True)代码提供问题:
def bulk_index_offers(index_name, id_field, docs):
actions = []
for doc in docs:
action = {
"_index": index_name,
"_type": index_name,
"_id": doc.get(id_field),
"_source": doc
}
actions.append(action)
# Error at this following line.
resp = helpers.bulk(es_repo, actions)
return resp我试过的是:
我尝试将块设置为更小的块,并将read_timeout从默认的10增加到30,如下所示:resp = helpers.bulk(es_repo, actions, chunks=500, read_timeout=30)
但仍然面临着同样的问题。
请帮帮忙。
发布于 2017-09-13 12:21:06
默认情况下,映射类型仅允许用于包含多达1000个字段,而且似乎超出了该限制。为了增加这个权限,您可以运行以下命令:
PUT mintegral_incent/_settings
{
"index": {
"mapping": {
"total_fields": {
"limit": "2000"
}
}
}
}如果用卷发,看起来会是这样的:
curl -XPUT http://<your.amazon.host>/mintegral_incent/_settings -d '{
"index": {
"mapping": {
"total_fields": {
"limit": "2000"
}
}
}
}'然后,您可以再次运行您的批量脚本,它应该可以工作。
发布于 2019-08-22 08:56:42
如果您想使用Python,请尝试:
import requests
headers = {
'Content-Type': 'application/json',
}
resp = requests.put('http://localhost:9200/your_index/_settings',
headers=headers,
data='{"index": {"mapping": {"total_fields": {"limit": "2000"}}}}')
print(f'\nHTTP code: {resp.status_code} -- response: {resp}\n')
print(f'Response text\n{resp.text}')您也可以使用上面所示的终端,尽管我必须添加一个标题-H'Content-Type: application/json'
curl -XPUT http://localhost:9200/your_index/_settings -d '{"index": {"mapping": {"total_fields": {"limit": "2000"}}}}' -H'Content-Type: application/json'如果您需要使用来自Python的curl请求(get、put、post),那么本指南是非常有用的(它是我的答案的来源),甚至提供了一个很好的方法来处理这个问题。
https://stackoverflow.com/questions/46197379
复制相似问题