I have a document with given structure:
{ "name" : "WF1", "myIndex" : [3, 4, 5] }
Lets say I have 4 of such records -
{ "name" : "WF1", "myIndex" : [3, 4, 5] }
{ "name" : "WF2", "myIndex" : [6, 7, 8] }
{ "name" : "WF3", "myIndex" : [9, 10, 11] }
{ "name" : "WF4", "myIndex" : [3, 6, 9] }
If I fire below "term" query:
GET myIndex/_search
{
"query": {
"terms": {
"qualsIndex": [
3, 6, 9, 20
]
}
}
}
It returns all 4 records. Whereas I only want to return a record that has 3,6, 9 i.e. only WF4. Basically, I want a result document that has a subset of input passed.
Note: I can tweak my document structure to achieve this. is it possible in OpenSearch?
TLDR;
To the best of my knowledge there is no solution in both ElasticSearch and OpenSearch. But I think you can hack you way through it, using
number
aswords
The Hack
Indexing the document with the field
myIndex
as a string of numbers. I can later search for those numbers, using the match query and the parameter such asminimum_should_match
.Will give you something like that:
This is not perfect and may lead to some edge cases, but this is the closest I could get to a "solution".