如何将一些 ElasticSearch 数据复制到新索引 [英] How to copy some ElasticSearch data to a new index

查看:27
本文介绍了如何将一些 ElasticSearch 数据复制到新索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的 ElasticSearch 中有电影数据,我是这样创建的:

Let's say I have movie data in my ElasticSearch and I created them like this:

curl -XPUT "http://192.168.0.2:9200/movies/movie/1" -d'
{
    "title": "The Godfather",
    "director": "Francis Ford Coppola",
    "year": 1972
}'

而且我有很多不同年份的电影.我想复制特定年份(例如 1972 年)的所有电影并将它们复制到70sMovies"的新索引中,但我不知道该怎么做.

And I have a bunch of movies from different years. I want to copy all the movies from a particular year (so, 1972) and copy them to a new index of "70sMovies", but I couldn't see how to do that.

推荐答案

从 ElasticSearch 2.3 开始,您现在可以使用内置的 _reindex API

Since ElasticSearch 2.3 you can now use the built in _reindex API

例如:

POST /_reindex
{
  "source": {
    "index": "twitter"
  },
  "dest": {
    "index": "new_twitter"
  }
}

或者通过添加过滤器/查询仅特定部分

Or only a specific part by adding a filter/query

POST /_reindex
{
  "source": {
    "index": "twitter",
    "query": {
      "term": {
        "user": "kimchy"
      }
    }
  },
  "dest": {
    "index": "new_twitter"
  }
}

阅读更多:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

这篇关于如何将一些 ElasticSearch 数据复制到新索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆