ElasticSearch: fuzzy模糊查询

Kibana的开发工具中执行:

1
2
3
4
5
6
7
8
9
10
GET /es_info/_search
{
  "query": {
    "fuzzy": {
      "address": {
        "value": "广东*"
      }
    }
  }
}

Java(Spring Data ElasticSearch):

1
2
3
4
NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder().withFields("id");
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
queryBuilder.must(QueryBuilders.fuzzyQuery("address","广东*"));
Query offlineQuery = nativeSearchQueryBuilder.withQuery(queryBuilder).build();

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

*

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据