【发布时间】:2020-07-04 02:40:14
【问题描述】:
对弹性搜索非常陌生
尝试使用 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 文件。当我从这个文件中删除别名时,我收到另一个关于不支持的映射参数的错误,所以我不确定问题出在哪里,但想先解决别名问题
【问题讨论】:
标签: python json elasticsearch