//创建,如果没有参数,会对所有索引运行 SearchRequest searchRequest = new SearchRequest(); //大多数搜索参数都能添加到SearchSourceBuilder,为进入搜索请求主体内容提供setter SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); //添加match_all查询到SearchSourceBuilder searchSourceBuilder.query(QueryBuilders.matchAllQuery()); //将SearchSourceBuilder添加到SeachRequest searchRequest.source(searchSourceBuilder);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); sourceBuilder.query(QueryBuilders.termQuery("user", "kimchy")); sourceBuilder.from(0); sourceBuilder.size(5); //设置超时时间控制允许搜索花费多长时间 sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
//创建一个全文匹配查询,在字段user上匹配文本kimchy MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("user", "kimchy"); //创建后,用QueryBuilder对象提供的放啊来配置它创建的搜索查询选项 //启用模糊查询 matchQueryBuilder.fuzziness(Fuzziness.AUTO); //设置前缀长度选项 matchQueryBuilder.prefixLength(3); //最大扩展 matchQueryBuilder.maxExpansions(10);
文章来源地址https://www.toymoban.com/news/detail-769382.html
文章来源:https://www.toymoban.com/news/detail-769382.html
到了这里,关于ElasticSearch集成SpringBoot实践的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!