【发布时间】:2016-10-05 20:46:37
【问题描述】:
我在 OS X 上使用 Node.JS 客户端运行 ElasticSearch 2.3.5。有时_suggest 端点会返回 0 个结果——这是随机发生的,例如在只有四个文档被索引的测试套件中。
建议者返回 0 个结果有什么原因吗?这导致我的测试有大约 50% 的时间失败。
测试套件经过以下步骤:
- 创建一个新的空白索引
- 为
title: {type: 'string'}的文档提供映射
- 为
- 使用
_bulkAPI 注入四个带有title字段的文档。- 我传递
refresh=true以确保文档被编入索引。
- 我传递
- 一个简单的测试查询文档。他们都在那里。
- 请求针对明显拼写错误的建议。 通过或失败的概率为 50/50
如果没有人可以提出任何明显的建议,我将创建一个独立的示例应用程序来证明这一点。
一个观察:小写拼写错误(例如,alhpa 代表 alpha 有 100% 成功;只有在引入创造性拼写错误时才会发生失败,例如 viTOR 代表 victor。不过,我很可能会想象这种行为,因为错误来来去去...)
附加:这是我为 ElasticSearch API 编写的包装函数:
didYouMean(input) {
return this.conn.suggest({
index: this.indexName,
type: 'customdoc',
body: {
titles: {
text: input,
phrase: {
field: 'title',
direct_generator: [{
// Only needs to be one character
// long to suggest a correction
field: 'title',
suggest_mode: 'always',
min_word_length: 1,
}],
highlight: {
pre_tag: '<strong><em>',
post_tag: '</em></strong>',
},
},
},
},
});
}
【问题讨论】:
标签: elasticsearch