实际上,Spring数据API(包含或startWith)不适用于String中的空间。我已经用Elastic core api实现了相同的功能。
NativeSearchQueryBuilder aNativeSearchQueryBuilder = new NativeSearchQueryBuilder(); aNativeSearchQueryBuilder.withIndices(indexName).withTypes(type); final BoolQueryBuilder aQuery = new BoolQueryBuilder(); aQuery.must(QueryBuilders.queryStringQuery("a b").defaultField("UserName"));NativeSearchQuery nativeSearchQuery = aNativeSearchQueryBuilder.withQuery(aQuery).build(); List<Object> aDatas = elasticsearchTemplate.queryForList(nativeSearchQuery, Object.class);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)