Hi... we have a nested mapping, which we'd like to reindex into a non-nested structure -
i.e. each nested object + the 'parent' document becomes a new document.
Is this possible by reindexing this structure using painless?
I tried to follow the guidelines from the URL below, but the problem is that by iterating the nested inner documents array within the parent, and assigning "ctx_source" fields the relevant values from the inner object, each document overrides the previous, so that at the end of the update, we only get a single document with the values from the last nested document it holds.
here is an example of a painless code as we tried to use it -
if (ctx._source.nestedObject instanceof List) { for (int i = 0; i < ctx._source.nestedObject.size(); i++) { ctx._source.text=ctx._source.nestedObject[i].text; ctx._source.lineNumber=ctx._source.nestedObjectinstanceof [i].lineNumber; ctx._source.someProperty=ctx._source.nestedObject [i].someProperty; }
Is there a way to flatten the nested documents as we want? so that if for example, we have a 1 outer document with 10 nested documents inside, at the end of the reindex process, we will have 10 flatten documents?