I am trying to retrieve a specific document with nested query on the identityLinks element.
My requirement:
- either identityLinks.userId should match specific userid when identityLinks.type is "assignee"
- OR identityLinks.groupId should match specific groupId when identityLinks.type is "candidate" OR "participant" or "watcher"
I am having one document x which matches condition 1 mentioned above at the same time the same document doesn't fit condition 2 above.
My query is not returning the document x me results when I add both condition in should clause.
However when I remove the condition 2 from should clause, I get hit for my document x.
Please suggest why it doesn't work with both the nested conditions in place in should clause.
Below is the relevant information for mappings and search query.
{
"from": 0,
"size": 25,
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"tenantId": "France"
}
}
],
"should": [
{
"term": {
"involvedUsers": "lipak"
}
},
{
"terms": {
"candidateGroups": [
"flowableUser",
"MANAGER"
]
}
}
],
"minimum_should_match": 1
}
},
"must": [
{
"bool": {
"should": [
{
"nested": {
"path": "identityLinks",
"query": {
"bool": {
"must": [
{
"term": {
"identityLinks.type": "assignee"
}
},
{
"match": {
"identityLinks.userId": "lipak"
}
}
]
}
}
}
},
{
"nested": {
"path": "identityLinks",
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"term": {
"identityLinks.type": "candidate"
}
},
{
"term": {
"identityLinks.type": "participant"
}
},
{
"term": {
"identityLinks.type": "watcher"
}
}
],
"minimum_should_match": 1
}
},
{
"terms": {
"identityLinks.groupId": [
"MANAGER"
]
}
}
]
}
}
}
}
],
"minimum_should_match": 1
}
},
{
"exists": {
"field": "endTime"
}
}
]
}
}
}
Mappings file:
{
"tasks-20230315-1456-29-53789055": {
"mappings": {
"dynamic": "strict",
"properties": {
"__flowableVersion": {
"type": "integer"
},
"assignee": {
"type": "keyword",
"copy_to": [
"full_text_typeAhead_workflow"
]
},
"candidateGroups": {
"type": "keyword"
},
"caseDefinitionCategory": {
"type": "keyword"
},
"caseDefinitionId": {
"type": "keyword"
},
"caseDefinitionKey": {
"type": "keyword"
},
"caseDefinitionName": {
"type": "keyword"
},
"caseInstanceName": {
"type": "keyword"
},
"category": {
"type": "text"
},
"categoryKeyword": {
"type": "keyword"
},
"claimTime": {
"type": "date"
},
"createTime": {
"type": "date"
},
"delegationStateString": {
"type": "keyword"
},
"description": {
"type": "text",
"copy_to": [
"full_text_typeAhead"
]
},
"dueDate": {
"type": "date"
},
"durationInMillis": {
"type": "long"
},
"endTime": {
"type": "date"
},
"executionId": {
"type": "keyword"
},
"formKey": {
"type": "keyword"
},
"fullTextVariables": {
"type": "text",
"analyzer": "ngrams",
"search_analyzer": "standard"
}
"id": {
"type": "keyword"
},
"identityLinks": {
"type": "nested",
"properties": {
"groupId": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"type": {
"type": "keyword"
},
"userId": {
"type": "keyword"
}
}
},
"involvedUsers": {
"type": "keyword"
},
"name": {
"type": "text",
"copy_to": [
"nameKeyword",
"full_text_typeAhead"
]
},
"nameKeyword": {
"type": "keyword"
},
"owner": {
"type": "keyword",
"copy_to": [
"full_text_typeAhead_workflow"
]
},
"parentScopeBusinessKey": {
"type": "keyword"
},
"parentScopeDefinitionCategory": {
"type": "text"
},
"parentScopeDefinitionId": {
"type": "keyword"
},
"parentScopeDefinitionKey": {
"type": "keyword"
},
"parentScopeDefinitionName": {
"type": "text"
},
"parentScopeId": {
"type": "keyword"
},
"parentScopeName": {
"type": "text"
},
"parentScopeType": {
"type": "keyword"
},
"parentTaskId": {
"type": "keyword"
},
"parentTaskName": {
"type": "keyword"
},
"priority": {
"type": "integer"
},
"processDefinitionCategory": {
"type": "keyword"
},
"processDefinitionId": {
"type": "keyword"
},
"processDefinitionKey": {
"type": "keyword"
},
"processDefinitionName": {
"type": "keyword"
},
"processInstanceId": {
"type": "keyword"
},
"processInstanceName": {
"type": "keyword"
},
"rootScopeBusinessKey": {
"type": "keyword"
},
"rootScopeDefinitionCategory": {
"type": "keyword"
},
"rootScopeDefinitionId": {
"type": "keyword"
},
"rootScopeDefinitionKey": {
"type": "keyword"
},
"rootScopeDefinitionName": {
"type": "text",
"copy_to": [
"full_text_typeAhead_workflow"
]
},
"rootScopeId": {
"type": "keyword"
},
"rootScopeName": {
"type": "text",
"copy_to": [
"full_text_typeAhead_workflow",
"rootScopeNameKeyword"
],
"analyzer": "ngrams",
"search_analyzer": "standard"
},
"rootScopeNameKeyword": {
"type": "keyword"
},
"rootScopeType": {
"type": "keyword"
},
"scopeDefinitionCategory": {
"type": "keyword"
},
"scopeDefinitionId": {
"type": "keyword"
},
"scopeDefinitionKey": {
"type": "keyword"
},
"scopeDefinitionName": {
"type": "keyword"
},
"scopeId": {
"type": "keyword"
},
"scopeType": {
"type": "keyword"
},
"startTime": {
"type": "date"
},
"subScopeId": {
"type": "keyword"
},
"suspensionState": {
"type": "integer"
},
"taskDefinitionId": {
"type": "keyword"
},
"taskDefinitionKey": {
"type": "keyword"
},
"taskModelName": {
"type": "keyword"
},
"tenantId": {
"type": "keyword"
},
"translations": {
"type": "nested",
"properties": {
"id": {
"type": "keyword"
},
"key": {
"type": "keyword"
},
"locale": {
"type": "keyword"
},
"scopeHierarchyType": {
"type": "keyword"
},
"value": {
"type": "text"
}
}
},
"variables": {
"type": "nested",
"properties": {
"booleanValue": {
"type": "boolean"
},
"dateValue": {
"type": "date"
},
"decimalValue": {
"type": "double"
},
"id": {
"type": "keyword"
},
"jsonValue": {
"type": "object",
"dynamic": "true",
"enabled": false
},
"name": {
"type": "keyword"
},
"numberValue": {
"type": "long"
},
"rawValue": {
"type": "text",
"index": false
},
"revision": {
"type": "integer"
},
"scopeDefinitionId": {
"type": "keyword"
},
"scopeDefinitionKey": {
"type": "keyword"
},
"scopeHierarchyType": {
"type": "keyword"
},
"scopeId": {
"type": "keyword"
},
"scopeType": {
"type": "keyword"
},
"textValue": {
"type": "text",
"analyzer": "ngrams",
"search_analyzer": "standard"
},
"textValueKeyword": {
"type": "keyword"
},
"type": {
"type": "keyword"
},
"variableTypeAhead": {
"type": "text",
"copy_to": [
"fullTextVariables"
]
}
}
}
}
}
}
}