Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档需要更新了 #146

Open
lmh793540604 opened this issue Aug 5, 2019 · 1 comment
Open

文档需要更新了 #146

lmh793540604 opened this issue Aug 5, 2019 · 1 comment

Comments

@lmh793540604
Copy link

更复杂的搜索
我们让搜索稍微再变的复杂一些。我们依旧想要找到姓氏为“Smith”的员工,但是我们只想得到年龄大于30岁的员工。我们的语句将添加过滤器(filter),它使得我们高效率的执行一个结构化搜索:
GET /megacorp/employee/_search
{
"query" : {
"filtered" : {
"filter" : {
"range" : {
"age" : { "gt" : 30 } <1>
}
},
"query" : {
"match" : {
"last_name" : "smith" <2>
}
}
}
}
}
该参数filtered已在ES 5.0中弃用并删除。您现在应该使用bool/must/filter查询。

@lmh793540604
Copy link
Author

现在查询应该为此种方法
{
"query": {
"bool": {
"must":{
"term" : { "last_name" : "smith" }
},
"filter": {
"range": {
"age": {
"gt": 30
}
}
}

    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant