Consider the below documents:
Documents
Doc 1
{
"id": [
"1a",
"1b",
"1c"
]
}
Doc 2
{
"id": [
"1a",
"1b"
]
}
Doc 3
{
"id": [
"1a"
]
}
Now if I search
For "id" : ["1a","1b"]
, then only doc 2 should match
For "id" : ["1a","1b","1d"]
, no documents should match
For "id" : ["1a"]
only document 3 should match
It is similar to the below java code implementation
import java.util.*;
class Test {
public static void main(String[] args)
{
List<String> list1 = Arrays.asList("One", "Two");
List<String> list2 = Arrays.asList("One","Two","Three");
boolean isMatch = list2.equals(list1);
System.out.println(isMatch);
}
}
With terms query and a query string, I attempted to build the above use case scenario, but it does not function for an exact match.
So, I think the best way should be to use the script, where I can loop through the values of the array list OR use equals
from Shared API to achieve this use case.
Can anyone please help me with the script for this?