[英]How to search case insensitive using wildcard elastic search java
I want to search case insensitive using wildcard.我想使用通配符搜索不区分大小写。
BoolQueryBuilder paramFilter = QueryBuilders.boolQuery();
paramFilter.must(QueryBuilders.wildcardQuery(field, "*"+key+"*"));
if you are running Elasticsearch > v7.10, you can set the case_insensitive
parameter of the wildcard query to true
.如果您正在运行 Elasticsearch > v7.10,则可以将通配符查询的case_insensitive
参数设置为true
。
otherwise, you can add to the mapping of your field a multi-field with a custom analyzer that sets a keyword
tokenizer and a lowercase
filter to the field's string.否则,您可以使用自定义分析器向字段的映射添加一个多字段,该分析器将keyword
标记器和小lowercase
滤器设置为字段的字符串。 This way, you'll be able to run your wildcard query against the multi-field.这样,您就可以针对多字段运行通配符查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.