elasticsearch-definitive-guide-cn icon indicating copy to clipboard operation
elasticsearch-definitive-guide-cn copied to clipboard

文档需要更新了

Open lmh793540604 opened this issue 6 years ago • 1 comments
trafficstars

更复杂的搜索 我们让搜索稍微再变的复杂一些。我们依旧想要找到姓氏为“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 avatar Aug 05 '19 02:08 lmh793540604

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

    }
}

}

lmh793540604 avatar Aug 05 '19 02:08 lmh793540604