elasticsearch - Elasticsearch 中的完成建议程序不起作用
问题描述
(使用 ES 6.7)我有一个索引并且想要支持 search-as-you-type 功能。为此,我想尝试完成建议,但我在重新索引以更改映射旧索引时遇到了麻烦。
这是旧的索引映射
{
"old-index": {
"mappings": {
"doc": {
"properties": {
"content": {
"type": "text"
},
"project": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "keyword"
}
}
}
}
}
}
这是新的测试索引映射
PUT test-completion
{
"mappings": {
"doc": {
"properties": {
"content": {
"type": "text",
"fields": {
"autocomplete": {
"type": "completion",
"contexts": [
{
"name": "project",
"type": "category",
"path": "project"
},
{
"name": "version",
"type": "category",
"path": "version"
}
]
}
}
},
"title": {
"type": "text"
},
"project": {
"type": "keyword"
},
"version": {
"type": "keyword"
}
}
}
}
}
这是重新索引查询
POST _reindex
{
"source": {
"index": "old-index"
},
"dest": {
"index": "test-completion"
}
}
这是不返回任何结果的查询
POST test-completion/_search
{
"suggest": {
"autocompletion_suggest": {
"prefix": "part of documentation",
"completion": {
"field": "content.autocomplete",
"fuzzy": {
"fuzziness": "AUTO"
},
"contexts": {
"project": "xyz-project",
"version": "abc-version"
}
}
}
}
}
如果前缀设置为a
or b
,它将返回上下文之外的结果。我在哪里做错了?
https://discuss.elastic.co/t/problem-with-completion-suggester/181695
解决方案
推荐阅读
- android - 滚动无法向上
- azure-resource-manager - ARM 访问 Azure Cosmos DB 中的 Gremlin 终结点
- python - 如何检查变量是否为字符串?
- java - 莫基托。正在创建的内部对象中的方法调用计数
- java - HttpServletReponse.sendRedirect 使用代理
- amazon-web-services - 如何处理重叠的后缀,s3事件通知的前缀
- r - R 中的条形图显示具有 3 个自变量的因变量的均值和标准差
- github-pages - 如何将 create-react-app 部署到 gh-pages 子文件夹?
- python - django cursor.execute("UPDATE...another model) 同时保存当前模型表单
- python - 从主继承类访问方法