简体   繁体   English

将多种类型从一个索引重新索引到另一索引中的单个类型

[英]Reindex multiple types from one index to single type in another index

I have two indexes: twitter and reitwitter 我有两个索引:twitter和reitwitter

twitter has multiple documents across different types like: twitter有多种不同类型的文档,例如:

"hits": [
{
"_index": "twitter",
"_type": "tweet",
"_id": "1",
"_score": 1,
"_source": {
"message": "trying out Elasticsearch"
}
},
{
"_index": "twitter",
"_type": "tweet2",
"_id": "1",
"_score": 1,
"_source": {
"message": "trying out Elasticsearch2"
}
},
{
"_index": "twitter",
"_type": "tweet1",
"_id": "1",
"_score": 1,
"_source": {
"message": "trying out Elasticsearch1"
}
}
]

Now, when I reindex, I wanted to get rid of all the different types and just use one because essentially they have the same field mappings. 现在,当我重新索引时,我想摆脱所有不同的类型,而只使用一种,因为本质上它们具有相同的字段映射。

I tried several different combinations but I always only get one document instead of those three: Approach 1: 我尝试了几种不同的组合,但是我总是只得到一份文档,而不是那三份:方法1:

POST _reindex/
{
"source": {
"index": "twitter"
}
,
"dest": {
"index": "reitwitter",
"type": "reitweet"
}
}

Response: 响应:

{
"took": 12,
"timed_out": false,
"total": 3,
"updated": 3,
"created": 0,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": []
}

Note : It says updated 3 because this was the second time I made the same call I guess? 注意:它说的是更新3,因为这是我第二次打同样的电话,我猜呢?

Second approach: 第二种方法:

POST _reindex/
{
"source": {
"index": "twitter",
"query": {
"match_all": {
}
}
}
,
"dest": {
"index": "reitwitter",
"type": "reitweet"
}
}

Same response as first one. 与第一个响应相同。

In both cases when I make this GET call: 在两种情况下,当我进行此GET调用时:

GET reitwitter/_search
{
"query": {
"match_all": {
}
}
}

I only get one document: 我只得到一份文件:

{
"_index": "reitwitter",
"_type": "reitweet",
"_id": "1",
"_score": 1,
"_source": {
"message": "trying out Elasticsearch1"
}

Is this use case even supported by reindex ? reindex是否支持此用例? If not, do I have to write a script using scan and scroll to get all the documents from source index and reindex them with same doc type in destination? 如果没有,我是否必须使用扫描和滚动编写脚本以从源索引中获取所有文档,并在目标位置使用相同的文档类型重新索引它们?

PS: I don't want to use "_source": ["tweet1", "tweet"] because I have around million doc type which have one document each that I want to map to the same doc type in the destination. PS:我不想使用“ _source”:[“ tweet1”,“ tweet”],因为我有大约一百万个文档类型,每个文档都有一个我想映射到目标中相同文档类型的文档。

The problem is that all the documents has the same id(1), and then they are overriding themselves during the re-index process. 问题在于所有文档都具有相同的id(1),然后在重新索引过程中它们将自己覆盖。

Try to index your documents with different ids and you will see it works. 尝试用不同的ID为您的文档建立索引,您将看到它可以正常工作。

暂无
暂无

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

相关问题 可以将特定类型的数据从具有多种类型的索引移动到具有一种类型的索引吗? - Possible to move data of a specific type from an index with multiple types to an index with one type? elasticsearch:单个索引中的多种类型 - elasticsearch: multiple types in a single index 如何将多个Elastic Search类型重新索引为一个类型的新索引? - How to re-index multiple Elastic Search types into a new index with a single type? ElasticSearch在单个索引中具有相同映射的多种类型 - ElasticSearch multiple types with same mapping in single index 显示单个_type中聚合的所有存储桶,其中一个索引包含具有相同字段名的多个_type - show all buckets from aggregation within a single _type where one index contains multiple _type with same field names 在ElasticSearch中,我必须创建单个索引和多个类型还是使用单个类型的多个索引? - In ElasticSearch i have to create single index and multiple types or multiple index with single types? 具有稀疏字段的单个_type是否对索引具有与多种类型(在ElasticSearch中)相同的索引? - Does a single _type with sparse fields have the same effect on the index as multiple types (in ElasticSearch)? 弹性搜索单个索引的多个映射 - Multiple Mappings in elastic search for one single Index ElasticSearch _reindex 产生“没有这样的索引” - ElasticSearch _reindex yields "no such index" 当使用 Reindex API 将数据从一个索引移动到另一个索引时,我可以使用脚本来检测是否存在匹配的文档并进行部分更新吗? - When using the Reindex API to move data from one index to another, can I use a script to detect if a matching doc exists and do a partial update?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM