elasticsearch的新手
[尝试使用elasticsearch-py api从json初始化索引;使用这个简单的json文件只是了解它的工作方式
{
"index": "index_name",
"body": {
"aliases": {
"actions": [
{ "add": { "index": "index_name", "alias": "alias1" } }
]
},
"mappings": {
"properties": {
"age": { "type": "integer" },
"email": { "type": "keyword" },
"name": { "type": "text" }
}
},
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1,
"index.refresh_interval": "120s"
}
}
}
((读取json文件,解析出index
和body
),然后是重要的python部分es.indices.create(index=index, body=body)
但是我遇到错误:
elasticsearch.exceptions.TransportError: TransportError(500, 'null_pointer_exception', 'fieldName cannot be null')
我从ES文档中提取了映射和别名示例。 python与另一个没有别名的json文件一起使用。当我从该文件中删除别名时,出现另一个错误,提示不支持的映射参数,因此我不确定问题出在哪里,但想先解决别名问题
正如source code的elasticsearch-py
所说,body
的indices.create
自变量不能包含任何别名:
正文:索引的配置(
settings
和mappings
)
话虽这么说,该库中有other methods使您可以创建别名。