我试图按照弹性搜索文档中的数组中的术语进行过滤。这就是文件的样子:
{
"name": "Foo",
"id": 10,
"industries": ["Tech", "Fashion"],
...
}
但是对于我尝试的各种基于过滤器的查询,我得到的结果为零。 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
}
'
我已针对各种简化和过滤条款尝试了十几种不同的查询,例如:这是一个简化的:
$ curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
{
"query": {
"filtered": {
"filter": {
"terms": {
"industries": ["Tech"],
"execution": "or"
}
}
}
},
"from": 0,
"size": 20
}
'
我在这里缺少什么?
答案 0 :(得分:1)
您在工业领域使用什么样的分析仪?如果您使用的是默认值,它实际上会降低案例并分割您的叮咬,这可以解释为什么您的过滤器不会选择这些文档(例如,它正在寻找" Tech"当只有" tech"存在时)。如果将映射设置为not_analyzed(或使用多字段选项),则可能会解决您的问题。