Im running into this error Error:
(QueryExceededMemoryLimitNoDiskUseAllowed) PlanExecutor error during aggregation :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.
here is my aggregation
collection
.aggregate([
{
$search: {
index: "default",
compound: {
should: [
{
text: {
query: search,
path: "name",
score: { boost: { value: 9 } },
fuzzy: {
maxEdits: 2,
maxExpansions: 2,
},
},
},
{
text: {
query: search,
path: "su",
score: { boost: { value: 100 } },
},
},
{
text: {
query: search,
path: "manufacturer_sku",
score: { boost: { value: 100 } },
},
},
{
text: {
query: search,
path: "internal_part_number",
score: { boost: { value: 100 } },
},
},
{
text: {
query: search,
path: "meta_keywords",
score: { boost: { value: 50 } }
},
},
],
},
sort: { unused: { $meta: "searchScore", order: -1 } },
},
},
{ $match: category },
{ $match: subcategory },
{ $match: brand },
{ $match: vehicle },
{ $match: { product_enabled: true } },
{ $match: { option_type: { $ne: "simple" } } },
{ $sort: sort },
{
$project: {
name: 1,
_id: 1,
sku: 1,
price: 1,
sale_price: 1,
thumbnail_url: 1,
reviews: 1,
product_image_links: 1,
brand: 1,
brand_code: 1,
category: 1,
subcategory: 1,
short_description: 1,
remove_watermark: 1,
option_type: 1,
score: { $meta: "searchScore" },
},
},
{
$facet: {
metadata: [{ $count: "total" }, { $addFields: { page: pageNumber } }],
categories: [
{
$project: {
category: 1,
subcategory: 1,
brand: 1,
sku: 1,
score: { $meta: "searchScore" },
},
},
],
data: [{ $skip: (pageNumber - 1) * pageLimit }, { $limit: pageLimit }],
},
}
], {allowDiskUse: true})
.toArray();