【发布时间】:2015-08-29 11:34:17
【问题描述】:
在映射或数据类型发生更改后,我对如何在弹性搜索中重新索引数据有点困惑。
根据弹性搜索文档
使用滚动搜索从旧索引中提取文档,并使用批量 API 将它们索引到新索引中。许多客户端 API 提供了一个 reindex() 方法,它将为您完成所有这些工作。完成后,您可以删除旧索引。
这是我的旧地图
{
"test-index2": {
"mappings": {
"business": {
"properties": {
"address": {
"type": "nested",
"properties": {
"country": {
"type": "string"
},
"full_address": {
"type": "string"
}
}
}
}
}
}
}
}
新的索引映射,我正在改变full_address -> location_address
{
"test-index2": {
"mappings": {
"business": {
"properties": {
"address": {
"type": "nested",
"properties": {
"country": {
"type": "string"
},
"location_address": {
"type": "string"
}
}
}
}
}
}
}
}
我正在使用 python 客户端进行弹性搜索
https://elasticsearch-py.readthedocs.org/en/master/helpers.html#elasticsearch.helpers.reindex
from elasticsearch import Elasticsearch
from elasticsearch.helpers import reindex
es = Elasticsearch(["es.node1"])
reindex(es, "source_index", "target_index")
但是,这会将数据从一个索引传输到另一个索引。
我如何使用它来更改上述案例的映射/(数据类型等)?
【问题讨论】:
标签: python elasticsearch