Hello, So I am currently trying to figure this out and would love to know if my current approach is correct and if not, is there a way to do it. So, the question is
We have these events coming in with each event having minimum 3 states. Now, the first one is a complete event but the rest are just the necessary information needed. The task is when these event comes in, form the complete event from its past state and add it to a new index. for e.g.
'''
State 1:
{
state : "create",
startTime: "2020-12-13T21:34:16.978Z",
lastUpdateTime : "2020-12-13T21:34:16.978Z",
id : "01",
name : "xyz",
data : ["abc","c"]
}
State 2:
{
state : "Inprogress",
lastUpdateTime : "2020-12-13T21:34:16.978Z",
id : "01"
}
State 3:
{
state : "Completed",
lastUpdateTime : "2020-12-13T21:34:16.978Z",
id : "01"
}
'''
As you can see not all states are coming with all the fields so when we create this docx in the new index we have to not only add updated fields but also the field that were not present in that particular state.
Some of the things that I have already looked into are :
Collapse : Does not work as it just gives the latest document.
Tranform(Latest) : Does not work as it just replaces with the latest document.
Would love to know if pivot transform would work or is there any other way to do this.