Each of my documents contain an array like
"idList": [
'DCCA7703Orange shirt',
'EFBA6705Blue bag',
'O7BA6405Blue socks'
]
I want to write a query to get only the documents where one or more of the elements of the "idList" array satisfy two conditions: that the value starts with one parameter and contains a second value parameter, all on the same element. For instance applying the logic to the example document above, if the parameters were "EFBA6705" and "bag" then it would be a hit, but not if the parameters were "EFBA6705" and "socks" since they are indeed in the array but on two different elements. This array is a property of type "text", I do not have control over the mappings of the document, so I cannot convert it to a "nested" type or any other type.
"idList": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
My elastic search version is 5.6.11.
Thanks in advance.
CodePudding user response:
Without changing mapping Wildcard query can work in this case
{
"query": {
"wildcard": {
"idList.keyword": {
"value": "EFBA6705* bag"
}
}
}
}