An external system generated many phases of customer journey. Phases like Anonymous, Registered, Subscriber etc. These are sent as events from a third party system who provides user management capabilities.
Events would look like below when the user reaches the website anonymously
{
"userId" : "343454,
"userName" : "",
"state" : "ANONYMOUS"
}
Next after creating the account
{
"userId" : "343454,
"userName" : "user1",
"state" : "REGISTERED"
}
After subscribing some line items
{
"userId" : "343454,
"userName" : "user1",
"state" : "SUBSCRIBED"
}
So if we create a user index we would have 3 documents
Same user now logs off and all tracking id's are lost and when he comes back we get a different user id and identified as anonymous user
{
"userId" : "1111,
"userName" : "",
"state" : "ANONYMOUS"
}
After login he will be directly moved to subscriber state because we know the user
{
"userId" : "1111,
"userName" : "user1",
"state" : "SUBSCRIBED"
}
A different user might chose to just register and not subscribe. So for him
{
"userId" : "2222,
"userName" : "",
"state" : "ANONYMOUS"
}
and
{
"userId" : "2222,
"userName" : "user2",
"state" : "REGISTERED"
}
And a complete anonymous user can be represented as
{
"userId" : "7876767,
"userName" : "",
"state" : "ANONYMOUS"
}
With such multiple states represented in these events would elastic search be able to provide us data like
"All users who are anonymous" or "How many users simply visited our site"
"All users who are registered" or "How many users own a account but not subscribed"
"All users who are subscribed" etc?
Above is typically can be done through DB. But we are seeing a real opportunity to use elastic search for other user cases where we need to perform search operations on document which are normalised.
Or above could be achieved if we model our user document differently?