I'm working on a project creating integration tests and the data I have includes all the schema updates people have done in the past. For example My "documents" field has a property of user, which has been an array in the past, but is now an Object.
I'm trying to write an integration test that will ONLY use a document if the user type is Object, not array.
Is there a way to do this with an ExistsQuery? So far I have not been able to find anything. Here's my current query which brings back inconsistent data:
GET _search
{
"query" : {
"bool" : {
"must" : {
"exists" : {
"document.user"
}
}
}
}
}
Ideally I'd like to check for document.user[] and filter those values out.
You can use script query like below