管理精确搜索和普通搜索索引的最佳方法是什么
我有一个用例,我需要正常的 match_all 搜索,即它也向我显示具有模糊结果的相关文档,但是我需要一个需要执行术语查询的特定搜索。 我的映射主要是字符串类型:
"project_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"projectabstract": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"task_number": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
我确实通过将 task_number 设置为关键字来尝试使用小写规范化器进行精确搜索,但发现我无法进行模糊搜索,因为它是一个关键字。由于小写规范化器仅适用于关键字,因此如果我将字段转换为关键字,我将无法获得从 type: string 获得的搜索结果。我应该维护两个索引,一个包含字符串,另一个包含关键字类型,还是有更好的替代方案?
I have a use case where I need normal match_all search i.e it shows me related documents with fuzzy results also, however I need a specific search which needs to do a term query.
My mappings are mostly string type:
"project_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"projectabstract": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"task_number": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
I did try exact search using lowercase normalizer by making task_number a keyword, but found out that I cant do a fuzzy search because it is a keyword. Since lowercase normalizer works only on keywords, if I convert the fields to keyword I cannot get search results I get from type: string. Should I maintain two indexes one with strings and another of type keyword or is there a better alternative to it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论