Es检索 must与filter区别

//组合查询对象,
//如搜索条件为“小米手机”这里must会分词为“小米”和“手机”这两个词是or关系
//加operator(Operator.AND)可以把or改为and关系
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(QueryBuilders.matchQuery("name",searchmap.get("keywords")).operator(Operator.AND));

//组合查询对象
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
//filter指不分词查询
boolQueryBuilder.filter(QueryBuilders.termQuery("brandName",searchmap.get("brand")));

版权声明:本文为weixin_45362084原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。