Hi! I'm trying to create an Elastic Search query to modify the data received but I don't have much knowledge about Elastic and I don't know how to accomplish that.
I have my "tasks" data with three properties, assignedToGroup, assignedToRole and assignedToUser.
This is the actual query that doesn't include the field assignedToRole because is new:
{
"_source": {
"includes": [
"taskId",
"tenantId-createdAt-circuitId",
"assignedToGroup",
"assignedToUser",
"circuitId",
"createdAt",
"createdByRole",
"currentStatus",
"taskType",
"tenantId",
"history",
"payload",
"slaExpiresAt",
"taskDefinitionName",
"taskDefinitionId",
"input"
]
},
"sort": [
{
"createdAt": {
"order": "desc"
}
}
],
"size": 20,
"from": 0,
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"match": {
"tenantId.keyword": "tenant1"
}
},
{
"range": {
"createdAt": {
"gte": "now-1y/d",
"lte": "now+1d/d"
}
}
}
],
"should": [
{
"match": {
"createdByGroup.keyword": "0"
}
},
{
"match": {
"assignedToGroup": "0"
}
}
]
}
},
"should": [
{
"match": {
"assignedToUser.keyword": "oficialsucursal1@btekstudio1.onmicrosoft.com"
}
},
{
"match": {
"createdByUser.keyword": "oficialsucursal1@btekstudio1.onmicrosoft.com"
}
}
]
}
}
}
This is my mapping https://pastebin.com/yE6PGLDQ
So as an user with specific group and role, I need to:
- Receive tasks assigned to the user
- Receive tasks assigned to the user's group
- Receive tasks assigned to the user's role
OR
- Receive tasks without role assigned but with user's group