【发布时间】:2020-07-31 05:33:26
【问题描述】:
我正在尝试实现MongoDB atlas search,目标是在 2 个字段上自动完成。
我目前有这个实现:
const searchStep = {
$search: {
// Read more about compound here:
// https://docs.atlas.mongodb.com/reference/atlas-search/compound/
compound: {
must: [
{
autocomplete: {
query,
path: 'name',
},
},
{
autocomplete: {
query,
path: 'description',
},
},
],
},
},
}
这似乎不起作用,似乎只有在 both 名称 AND 描述匹配时才起作用。我该如何解决这个问题,所以我查询 名称和描述?
我现在尝试使用 通配符 选项:
{
wildcard: {
query,
path: ['name', 'description'],
allowAnalyzedField: true,
}
}
但通配符解决方案似乎不起作用 - 没有返回相关结果...
【问题讨论】: