我正在尝试在Elastic 2.X中创建过滤的索引别名
以下是所有性别的青少年。我只想在此过滤器中看到女性。
这就是我要创建索引别名的内容:
"add" : {
"index" : "myindex",
"alias" : "teenage_female",
"filter" :
{
"bool" :
{
"must" :
[
{ "term": { "gender": "female" } },
{ "range": { "age": { "gt": "12", "lt": "20" } } }
]
}
}
}
}
我看过这个问题,似乎是相同的答案,但是JSON中肯定有问题。
Elasticsearch connect range and term to same array item
最佳答案
过滤器不能是数组,除非将其包装在带有“必须”的“ bool(boolean) ”中。
以下过滤器正常工作:
"filter" :
{
"bool" :
{
"must" :
[
{ "term": { "gender": "female" } },
{ "range": { "age": { "gt": "12", "lt": "20" } } }
]
}
}
关于elasticsearch - elasticsearch范围和项过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44855919/