java - elasticsearch normalizer 不适用于小写
问题描述
我为该字段创建了以下规范化器,code
以根据大小写查询弹性搜索。
PUT my_index12
{
"settings": {
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"char_filter": [],
"filter": ["lowercase", "asciifolding"]
}
}
}
},
"mappings": {
"doc": {
"properties": {
"code": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}
}
并且我尝试使用通配符查询进行搜索,但没有得到任何结果,没有规范化器就可以使用大写字母,这在 elasticsearch 中是如何出现的
get my_index12/_search
{
"query": {
"wildcard": {
"code.keyword": {
"value": "*AB-7000-5000-Wk-21*"
}
}
}
}
请在下面找到我的索引
{
"_index": "my_index12",
"_type": "doc",
"_id": "2",
"_score": 1,
"_source": {
"code": "ABCq123S"
}
},
{
"_index": "my_index12",
"_type": "doc",
"_id": "1",
"_score": 1,
"_source": {
"code": "AB-7000-5000-Wk-21"
}
}
如果我尝试为code.keyword
"mappings": {
"doc": {
"properties": {
"code.keyword": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
将文档插入索引时出现以下错误
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "object mapping for [code] tried to parse field [code] as object, but found a concrete value"
}
],
"type": "mapper_parsing_exception",
"reason": "object mapping for [code] tried to parse field [code] as object, but found a concrete value"
},
"status": 400
}
解决方案
推荐阅读
- git - Git credential helper=wincred 和 osxchain 在同一台机器上
- angular - 在tomcat 9上刷新页面Angular 404时出错
- javascript - 在 jquery datepicker 中启用一个特定日期
- java - 从日期开始计时
- javascript - 访问封装的匿名函数
- c# - 索引超出范围。无法将 selectedIndexChanged 作为查询索引
- python - 选择列表的前 20%,然后选择列表的下 20%
- c++ - Codesynthesis - 将字符串值与 C++ 中的序列进行比较
- vb.net - 如果使用 Or 关键字不满足条件
- python - 递归目录查找文件使用 fileInput 模块替换字符串。如何?