I am currently changing my ElasticSearch schema.
I previously had one type Product
in my index with a nested field Product.users
.
And I now wants to get 2 different indices, one for Product
, an other one for User
and make links between both in code.
I use reindex
API to reindex all my Product
documents to the new index, removing the Product.users
field using script:
ctx._source.remove('users');
But I don't know how to reindex all my Product.users
documents to the new User
index as in script I'll get an ArrayList of users
and I want to create one User
document for each.
Does anyone knows how to achieve that?
For those who may face this situation, I finally ended up reindexing users
nested field using both scroll
and bulk
APIs.
scroll
API to get batches of Product
documentsProduct
documentsProduct.users
User
document and add it to a bulkProduct
batchDoing the job <3