Reputation: 21
ES newbie here. I want to move documents from one index to another, based on a criterion. I've been using the Reindex API, specifically the version that takes a query - docs here: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
I've been POST-ing the following query to <root_es_uri>/_reindex
.
{
"source": {
"index": <EXISTING_SOURCE_INDEX>,
"type": "_doc",
"query": {
"term": {
"domain": <A SPECIFIC DOMAIN>
}
}
},
"dest": {
"index": <AN EXISTING EMPTY INDEX>
}
}
Running this yields the following:
{
"took": 37,
"timed_out": false,
"total": 0,
"updated": 0,
"created": 0,
"deleted": 0,
"batches": 0,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": []
}
So it "succeeds", but picks up no documents to move. When I run the query from the _reindex
call against the _search
endpoint of the source index, it returns all the documents I want moved, so I know my query is legitimate. At first I thought that perhaps the source index is configured not to allow reindexing like this, but I ran a _reindex
command without the query (ie, copying all documents from the source index) and it worked. Thanks in advance!
Upvotes: 1
Views: 814
Reputation: 21
I fixed it. The problem was the _type
field on the request; the documents I was interested in moving did not have type _doc
. Changing this field to the appropriate value solved the issue.
Upvotes: 1