Elastic Search Lowercase 分析器不返回搜索结果
我有一个基于文本的索引,如下所示。我试图根据用户输入的标记来维护精确搜索和模糊搜索。虽然基于文本的搜索工作正常(部分搜索),但当涉及术语搜索时,它会返回数据,前提是大小写相同。 我确实尝试添加基于小写过滤器的分析器,但它没有帮助。我在这里能做什么?
映射:
"project_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"projectabstract": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
基于小写分析器的新索引:
PUT /project_term_search_text_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"rebuilt_standard": {
"tokenizer": "standard",
"filter": [
"lowercase"
]
}
}
}
},
"mappings": {"project_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"projectabstract": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},}
我应该如何更新索引以在这两种情况下工作。
I have a text based index like below. I am trying to maintain both exact search and ambiguous search based on tokens based on user input. While text based search works fine(partial search) when it comes to term search it returns data iff case is the same.
I did try adding a lowercase filter based analyzer but it does not help. What can I do here?
Mappings:
"project_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"projectabstract": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
New index based on lowercase analyzer:
PUT /project_term_search_text_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"rebuilt_standard": {
"tokenizer": "standard",
"filter": [
"lowercase"
]
}
}
}
},
"mappings": {"project_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"projectabstract": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},}
How should I update my index to work in both cases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用适用于关键字字段。您还可以自定义规范化器(如分析器),在链接中您可以找到带有小写过滤器的相关示例,这将解决您的问题。
You need to use the normalizer which works on the keyword fields. You can also customize your normalizer like analyzer, In the link you can find the relevant example with lowercase filter, which would solve your issue.