简体   繁体   English

Elasticsearch重新索引

[英]Elasticsearch Reindex

Theres an index that I want to apply updated mappings to, I have done my best to follow the documentation on ES and Stackoverflow but I am now stuck. 有一个索引,我想将更新的映射应用于该索引,我已尽力按照ES和Stackoverflow上的文档进行操作,但现在遇到了麻烦。

The original index: logstash-index-YYYY.MM with data in it 原始索引: logstash-index-YYYY.MM其中包含数据
I created index: logstash-index-new-YYYY.MM (which has a template for the new mapping) 我创建了索引: logstash-index-new-YYYY.MM (它具有新映射的模板)

Using the following query: 使用以下查询:
/logstash-index-YYYY.MM/_search?search_type=scan&scroll=1m
{ "query": { "match_all": {} }, "size": 30000 } {“ query”:{“ match_all”:{}},“ size”:30000}

I get a _scroll_id and I have less than 30k docs so I should only need to run once. 我得到一个_scroll_id并且文档少于30k,所以我只需要运行一次。

How do I use that id to push the data into the new index? 如何使用该ID将数据推送到新索引中?

You are not using scrollid to push the data into the new index. 您没有使用scrollid将数据推入新索引。 You use it to get another portion of data from the scroll query. 您可以使用它来从滚动查询中获取另一部分数据。

When you run scan query, first pass doesn't return any results, it scans through shards in your cluster and returns scrollid. 当您运行扫描查询时,首次通过不会返回任何结果,它会扫描集群中的分片并返回scrollid。 Another pass (using scrollid from first one) will return actual results. 另一遍(使用第一个的scrollid)将返回实际结果。

If you want to put that data into new index you should write some kind of simple program in language of your choice that will get this data and then put it into your new index. 如果要将数据放入新索引中,则应使用自己选择的语言编写某种简单程序,该程序将获取该数据,然后将其放入新索引中。

There is a very good article on elasticsearch blog how to change mappings of your indices on the fly. elasticsearch博客上有一篇非常好的文章 ,介绍如何动态更改索引的映射。 Unfortunately, reindexing itself is not covered there. 不幸的是,重新编制索引本身不包括在此处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM