We're collecting all the events in our application and storing them along with a session identifier. I've an use case where i want to find the sessions where users navigate from say login page to product page to cart page . We're consolidating all the events happening to an entity centric index (based on session identifier) and all events are stored as a nested field.
sample document
{"session_id": 1, "paths": [{"event": "pageload", "view": "A", "timestamp": 1589584620000}, {"event": "pageload", "view": "C", "timestamp": 1589584680000}, {"event": "pageload", "view": "B", "timestamp": 1589584700000}]}
I tried the below query
POST entity_index/_search
{
"size": 0,
"query": {
"bool": {
"must": [
]
}
},
"aggs": {
"step1": {
"filter": {
"nested": {
"path": "paths",
"query": {
"match": {"paths.view": "A"}
}
}
},
"aggs": {
"step2": {
"filter": {
"nested": {
"path": "paths",
"query": {
"match": {"paths.view": "D"}
}
}
},
"aggs": {
"step3": {
"filter": {
"nested": {
"path": "paths",
"query": {
"match": {"paths.view": "B"}
}
}
}
}
}
}
}
}
}
}
But the order of navigations is not maintained . Is it possible to achieve my use case without using script aggregation ? Is Elastic search suitable for this use case or should we try other graph databases?