ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
Java代码 对象中设置得为 keyword `@Field(type = FieldType.Keyword)` ``` BoolQueryBuilder builder = QueryBuilders.boolQuery(); // 手机号模糊查询 String phone = bo.getPhone(); if (StringUtils.isNotBlank(phone)) { phone = "*"+phone+"*"; BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); WildcardQueryBuilder phoneBuilder = QueryBuilders.wildcardQuery("phone", phone); WildcardQueryBuilder morePhoneBuilder = QueryBuilders.wildcardQuery("morePhone", phone); boolQueryBuilder.should(phoneBuilder); boolQueryBuilder.should(morePhoneBuilder); builder.must(boolQueryBuilder); } ``` 生成的条件修改后放到 kibana 中 ``` POST /contacts_index/_search { "query": { "bool" : { "must" : [ { "bool" : { "should" : [ { "wildcard" : { "phone" : { "wildcard" : "*31467793*", "boost" : 1.0 } } } ], "adjust_pure_negative" : true, "boost" : 1.0 } } ], "adjust_pure_negative" : true, "boost" : 1.0 } } } ```