All my documents have a field, tags
of type Array
. I want to search and return all the documents that have an intersection of tags
with a user-input array. The number of elements is variable, not a fixed size.
Examples:
tags:["python", "flask", "gunicorn"]
input:["python"]
- This would return
true
because all the elements ininput
is intags
.
tags:["nginx", "pm2"]
input:["nodejs", "nginx", "pm2", "microservice"]
- This would return
false
because"nodejs"
and"microservice"
is not intags
.
I looked into terms
query but I do not think it works for arrays.
I also found this, Elasticsearch array property must contain given array items, but the solution is for old versions of Elasticsearch and the syntax has changed.