gpt4 book ai didi

$limit and $count not working when using $seach & $match together - Atlas Search(同时使用$seach和$Match时,$Limit和$count不起作用-Atlas Search)

转载 作者:bug小助手 更新时间:2023-10-28 13:37:27 28 4
gpt4 key购买 nike



let pipeline = [
{
$search: {
index: indexes.CAREERS_SEARCH_INDEX,
compound: {
should: [
{
autocomplete: {
query: searchText,
path: 'role_title',
fuzzy: {
maxEdits: 1,
},
}
},
{
autocomplete: {
query: searchText,
path: 'industry',
fuzzy: {
maxEdits: 1,
},
}
},
{
autocomplete: {
query: searchText,
path: 'overview',
fuzzy: {
maxEdits: 1,
},
}
},
],
},
},
},
];

if (industries && industries.length) {
pipeline.push({
$match: { industry: { $in: industries } },
});
}

pipeline.push({
$limit: limit
});

pipeline.push({
$group: {
_id: null,
search_results: { $push: "$$ROOT" },
matched_count: { $sum: 1 }
}
});

pipeline.push({
$project: {
_id: 0,
search_results: 1,
matched_count: 1
}
});

let results = await CareerModel.aggregate(pipeline);
results = results[0];
data.careers = results.search_results;
data.count = results.matched_count;
return data;

If the results are 40 then limiting the results to 10 changes the matched_count to 10 as well when it should be 40 actually. The mongoose documentation on atlas search is very limited and does not cover cases like these. If you have faced a similar issue, it would be great if you can just point me in the right direction. Thanks!

如果结果是40,那么将结果限制为10也会将MATCHED_COUNT更改为10,而实际上它应该是40。关于atlas搜索的Mongoose文档非常有限,不包括这样的情况。如果你遇到过类似的问题,如果你能为我指出正确的方向,那就太好了。谢谢!


更多回答
优秀答案推荐
更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com