I'm trying to filter by terms within an array on elasticsearch documents. This is what the documents look like:
{
"name": "Foo",
"id": 10,
"industries": ["Tech", "Fashion"],
...
}
But for the various filter-based queries I try, I've gotten zero results. e.g.:
$ curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [{
"terms": {
"industries": ["Tech"],
"execution": "or"
}
}]
}
},
"query": {"match_all": {}}
}
},
"from": 0,
"size": 20
}
'
I've tried about a dozen different queries against various simplifications and filter clauses, e.g. here's a simplified one:
$ curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
{
"query": {
"filtered": {
"filter": {
"terms": {
"industries": ["Tech"],
"execution": "or"
}
}
}
},
"from": 0,
"size": 20
}
'
What am I missing here?
not_analyzed(or use themulti fieldsoption), that might solve your problem.