1 term query 分词精确查询
QueryBuilder queryBuilder = QueryBuilders.termQuery("name", "华为手机");
2 terms Query 多term查询
QueryBuilder queryBuilder = QueryBuilders.termsQuery("name", "华为手机","摄像机");
3 range query 范围查询
QueryBuilder queryBuilder=QueryBuilders.rangeQuery("price").gte(5000).lt(10000);
4 exist query 查询字段不为null的文档
QueryBuilder queryBuilder= QueryBuilders.existsQuery("introduce");
5 prefix query 匹配分词前缀 如果字段没分词,就匹配整个字段前缀
QueryBuilder queryBuilder=QueryBuilders.prefixQuery("name","华");
6 wildcard query 通配符查询,支持* 任意字符串;?任意一个字符
QueryBuilder queryBuilder=QueryBuilders.wildcardQuery("name","华*");
QueryBuilder queryBuilder=QueryBuilders.wildcardQuery("name","ctr?")
7 regexp query 正则表达式匹配分词,正则表达式自己写吧
QueryBuilder queryBuilder=QueryBuilders.regexpQuery("name","华.*");
8 fuzzy query 分词模糊查询,通过增加fuzziness 模糊属性,来查询term 如下能够匹配 name 为 耳 耳前或后加一个字母的term的 文档 fuzziness 的含义是检索的term 前后增加或减少n个单词的匹配查询,
QueryBuilder queryBuilder=QueryBuilders.fuzzyQuery("name","耳").fuzziness(Fuzziness.ONE);
9 type Query 查询某个type的数据
QueryBuilder queryBuilder=QueryBuilders.typeQuery("digital");
10 idx Query 根据ID查询
QueryBuilder queryBuilder=QueryBuilders.idsQuery().addIds("AWelj9EHIRUqnC6X38Sj","AWelnJvnIRUqnC6X38Sv","AWemejYdIRUqnC6X38Sz");