开发者学堂课程【ElasticSearch 入门精讲:过滤 filter】学习笔记,与课程紧密连接,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/631/detail/9996
过滤 filter
ES 查询详解之过滤 filter
.setPostFilter(FilterBuilders.rangeFilter("age'").from(1).to(19))
/** *带过滤条件的查询 * 查询索引库之 bank 中的 type 之 account 下所有年龄在20~25之间的账户信息 */ @Test public void testFilter()( client.prepareSearch( indices: "bank") .setTypes("account") .setFrom(0) .setSize(1000) .setPostFilter(QueryBuilders.rangeQuery name: " age").gte(20)) .setPostFilter(QueryBuilders.rangeQuery name: "age"),.lte(25)) .get(); //②分析查询后的结果 SearchHits hits = response.getHits(); System. out.println("__”); for (SearchHit hit : hits) { System. out.println( hit.getSourceAsString)); } |