假设我的ElasticSearch中有电影数据,我就像这样创建它们:
curl -XPUT "http://192.168.0.2:9200/movies/movie/1" -d'
{
"title": "The Godfather",
"director": "Francis Ford Coppola",
"year": 1972
}'
Run Code Online (Sandbox Code Playgroud)
我有一堆不同年代的电影.我想所有的电影从某个特定年份(因此,1972年),复制并拷贝到"70sMovies"的新指标,但我看不出如何做到这一点.
Lud*_*ord 105
从ElasticSearch 2.3开始,您现在可以使用内置_reindexAPI
例如:
POST /_reindex
{
"source": {
"index": "twitter"
},
"dest": {
"index": "new_twitter"
}
}
Run Code Online (Sandbox Code Playgroud)
或者只通过添加过滤器/查询来指定特定部分
POST /_reindex
{
"source": {
"index": "twitter",
"query": {
"term": {
"user": "kimchy"
}
}
},
"dest": {
"index": "new_twitter"
}
}
Run Code Online (Sandbox Code Playgroud)
阅读更多:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
KWu*_*icz 47
最好的方法是使用elasticsearch-dump工具https://github.com/taskrabbit/elasticsearch-dump.
我使用的现实世界的例子:
elasticdump \
--input=http://localhost:9700/.kibana \
--output=http://localhost:9700/.kibana_read_only \
--type=mapping
elasticdump \
--input=http://localhost:9700/.kibana \
--output=http://localhost:9700/.kibana_read_only \
--type=data
Run Code Online (Sandbox Code Playgroud)
查看背包:https: //github.com/jprante/elasticsearch-knapsack
一旦安装并运行了插件,就可以通过查询导出部分索引.例如:
curl -XPOST 'localhost:9200/test/test/_export' -d '{
"query" : {
"match" : {
"myfield" : "myvalue"
}
},
"fields" : [ "_parent", "_source" ]
}'
Run Code Online (Sandbox Code Playgroud)
这将仅使用您的查询结果创建一个tarball,然后您可以将其导入另一个索引.
将特定类型从源索引重新索引到目标索引类型的语法是
POST _reindex/
{
"source": {
"index": "source_index",
"type": "source_type",
"query": {
// add filter criteria
}
},
"dest": {
"index": "dest_index",
"type": "dest_type"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
65860 次 |
| 最近记录: |