如何在springmongo视图创建中添加allowDiskUse:true



我正在Springboot应用程序的Mongo-Db中创建一个视图。以下是同一的代码


[{
$sort: {
event_trigger_date: -1
}
}, {
$group: {
_id: {
"profile_id": "$profile_id"
},
data: {
$first: "$$ROOT"
}
}
}, {
$unset: "_id"
}, {
$replaceRoot: {
newRoot: "$data"
}
}, {
$project: {
"profile_id": 1
}
}, {
$lookup: {
from: 'profile_event',
localField: 'profile_id',
foreignField: 'profile_id',
as: 'profile_event_data'
}
}, {
$group: {
_id: {
"profile_id": "$profile_id"
},
data: {
$first: "$$ROOT"
}
}
}, {
$replaceRoot: {
newRoot: "$data"
}
}, {
$project: {
profile_id: 1,
profile_event_data: 1,
event_type_set: {
$concatArrays: ["$profile_event_data.event_type"]
}
}
}, {
$addFields: {
_id: {
$concat: ["ACTIONS_NOT_COMPLETED_0X:", "$profile_id"]
},
event_type: "ACTIONS_NOT_COMPLETED_NX",
event_trigger_date: "$$NOW",
event_occurence: 0,
trigger_status: "SILENT"
}
}, {
$unset: "event_exists"
}, {
$lookup: {
from: 'profile_personal_info',
localField: 'profile_id',
foreignField: 'profile_id',
as: 'personal_info'
}
}, {
$project: {
profile_id: 1,
event_type: 1,
event_trigger_date: 1,
event_occurence: 1,
trigger_status: 1,
event_type_set: 1,
personal_info: {
$arrayElemAt: ["$personal_info", 0]
}
}
}, {
$addFields: {
oldest_personal_info_created_date: {
$trunc: {
$divide: [{
$subtract: ["$$NOW", '$personal_info.created_date']
}, 1000 * 60 * 60 * 24]
}
}
}
}, {
$addFields: {
created_date: {
$trunc: {
$divide: [{
$subtract: ["$$NOW", '$event_trigger_date']
}, 1000 * 60 * 60 * 24]
}
}
}
}, {
$project: {
event_type: 1,
profile_id: 1,
event_trigger_date: 1,
profile_event_data: 1,
event_type_set: 1,
event_occurence: 1,
trigger_status: 1,
category_value: {
$cond: {
if: {
$eq: ["$oldest_personal_info_created_date", null]
},
then: "$created_date",
else: "$oldest_personal_info_created_date"
}
}
}
}, {
$project: {
profile_id: 1,
event_type: 1,
event_type_set: 1,
event_trigger_date: 1,
event_occurence: 1,
trigger_status: 1,
category_value: 1,
"event_exists": {
$in: ["ACTIONS_NOT_COMPLETED_NX", "$event_type_set"]
}
}
}, {
$match: {
event_exists: {
$ne: true
}
}
}, {
$unset: ["event_exists", "event_type_set"]
}]

我想添加allowDiskUse:true条件,因为我得到以下错误

Stacktrace:|/java.lang.Exception:[profile_event_view@stage[副本集:]]数据库错误!|___/Mongo服务器错误(MongoQueryException(:查询失败,错误代码为292,错误消息为"聚合期间PlanExecutor错误::原因::排序超过33554432字节的内存限制,但未选择外部排序。">

如何在代码中添加allowDiskUse:true以避免上述错误?

真的是一个巨大的管道。我认为还有很大的优化空间。

例如,如果我没有错,这些阶段

[
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"profile_event_data": 1,
"filteredList": { "$filter": { "input": "$profile_event_data", "as": "item", "cond": { "$eq": ["$$item.event_type", "ACTIONS_COMPLETED_DAILY"] } } }
}
},
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"profile_event_data": 1,
"filteredList": 1,
"lastfilteredlist": { "$arrayElemAt": ["$filteredList", -1] }
}
},
{ "$unset": ["profile_event_data", "filteredList"] },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"latest_daily_action_creation_date": "$lastfilteredlist.created_date"
}
},
{ "$addFields": { "latest_daily_action_created_date": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$latest_daily_action_creation_date"] }, 86400000] } } } },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"latest_daily_action_created_date": 1,
"category_value": { "$cond": { "if": { "$eq": ["$latest_daily_action_created_date", null] }, "then": "$oldest_lifebandinfo_created_date", "else": "$latest_daily_action_created_date" } }
}
},
{ "$unset": ["oldest_lifebandinfo_created_date", "latest_daily_action_created_date"] }]
]

你可以简单地写如下。它不会使聚合管道更快,但更容易阅读:

[
{
"$set": {
"filteredList": { "$filter": { "input": "$profile_event_data", "as": "item", "cond": { "$eq": ["$$item.event_type", "ACTIONS_COMPLETED_DAILY"] } } }
}
},
{
"$project": {
"latest_daily_action_created_date": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", { "$arrayElemAt": ["$filteredList.created_date", -1] }] }, 86400000] } },
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"category_value": { "$cond": { "if": { "$eq": ["$latest_daily_action_created_date", null] }, "then": "$oldest_lifebandinfo_created_date", "else": "$latest_daily_action_created_date" } }
}
}
]

注意,$project中不存在的每个字段都将被删除。您也可以使用"$$REMOVE"而不是单独的$unset阶段,例如

{
"$addFields": {
"event_trigger_date": "$lifeband_info.created_date",
"filteredList": "$$REMOVE"
}
}

另一个例子:

[
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{ "$project": { "profile_id": 1 } },
]

成为

[
{ "$project": { "profile_id": "$data.profile_id", _id: 0 } }
]

你运行12次

{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } }

尝试只运行一次,多次重用结果(即data字段(。操作CCD_ 5可以以较少的努力提供相同的操作。

这同样适用于18(!($lookup。每个集合只联接一次,然后重用联接的数据。

重新格式化的管道:

db.profile_event.aggregate([
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{
"$project": {
"profile_id": 1
}
},
{ "$lookup": { "from": "profile_event", "localField": "profile_id", "foreignField": "profile_id", "as": "profile_event_data" } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$replaceRoot": { "newRoot": "$data" } },
{
"$project": {
"profile_id": 1,
"profile_event_data": 1,
"event_type_set": { "$concatArrays": ["$profile_event_data.event_type"] }
}
},
{
"$addFields": {
"_id": { "$concat": ["ACTIONS_NOT_COMPLETED_0X:", "$profile_id"] },
"event_type": "ACTIONS_NOT_COMPLETED_NX",
"event_trigger_date": "$$NOW",
"event_occurence": 0,
"trigger_status": "SILENT"
}
},
{ "$unset": "event_exists" },
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_id", "foreignField": "profile_id", "as": "lifeband_info" } },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"event_type_set": 1,
"lifeband_info": { "$arrayElemAt": ["$lifeband_info", 0] }
}
},
{ "$addFields": { "oldest_lifebandinfo_created_date": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$lifeband_info.created_date"] }, 86400000] } } } },
{ "$addFields": { "created_date": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$event_trigger_date"] }, 86400000] } } } },
{
"$project": {
"event_type": 1,
"profile_id": 1,
"event_trigger_date": 1,
"profile_event_data": 1,
"event_type_set": 1,
"event_occurence": 1,
"trigger_status": 1,
"category_value": { "$cond": { "if": { "$eq": ["$oldest_lifebandinfo_created_date", null] }, "then": "$created_date", "else": "$oldest_lifebandinfo_created_date" } }
}
},
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_type_set": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1, "category_value": 1, "event_exists": { "$in": ["ACTIONS_NOT_COMPLETED_NX", "$event_type_set"] }
}
},
{ "$match": { "event_exists": { "$ne": true } } },
{ "$unset": ["event_exists", "event_type_set"] },
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$match": { "event_type": { "$eq": "ACTIONS_NOT_COMPLETED_NX" } } },
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{ "$unset": ["last_modified_date", "notification_type", "progress_status"] },
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_id", "foreignField": "profile_id", "as": "lifeband_info" } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$replaceRoot": { "newRoot": "$data" } },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"filteredList": 1,
"lifeband_info": { "$arrayElemAt": ["$lifeband_info", 0] }
}
},
{ "$addFields": { "oldest_lifebandinfo_created_date": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$lifeband_info.created_date"] }, 86400000] } } } },
{ "$lookup": { "from": "profile_event", "localField": "profile_id", "foreignField": "profile_id", "as": "profile_event_data" } },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"profile_event_data": 1,
"filteredList": { "$filter": { "input": "$profile_event_data", "as": "item", "cond": { "$eq": ["$$item.event_type", "ACTIONS_COMPLETED_DAILY"] } } }
}
},
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"profile_event_data": 1,
"filteredList": 1,
"lastfilteredlist": { "$arrayElemAt": ["$filteredList", -1] }
}
},
{ "$unset": ["profile_event_data", "filteredList"] },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"latest_daily_action_creation_date": "$lastfilteredlist.created_date"
}
},
{ "$addFields": { "latest_daily_action_created_date": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$latest_daily_action_creation_date"] }, 86400000] } } } },
{
"$project": {
"profile_id": 1,
"event_type": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"oldest_lifebandinfo_created_date": 1,
"latest_daily_action_created_date": 1,
"category_value": { "$cond": { "if": { "$eq": ["$latest_daily_action_created_date", null] }, "then": "$oldest_lifebandinfo_created_date", "else": "$latest_daily_action_created_date" } }
}
},
{ "$unset": ["oldest_lifebandinfo_created_date", "latest_daily_action_created_date"] }]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{ "$project": { "profile_id": 1 } },
{ "$lookup": { "from": "profile_event", "localField": "profile_id", "foreignField": "profile_id", "as": "profile_event_data" } },
{
"$project": {
"profile_id": 1,
"event_type_set": { "$concatArrays": ["$profile_event_data.event_type"] }
}
},
{
"$project": {
"profile_id": 1,
"event_exists": { "$in": ["HEALTH_FACTORS_NX", "$event_type_set"] }
}
},
{ "$match": { "event_exists": { "$ne": true } } },
{
"$addFields": {
"_id": { "$concat": ["HEALTH_FACTORS_0X:", "$profile_id"] },
"event_type": "HEALTH_FACTORS_NX",
"event_occurence": 0,
"trigger_status": "SILENT"
}
},
{ "$unset": "event_exists" },
{
"$addFields": {
"lifeband_event_id": { "$concat": ["lifeband:", "$profile_id"] }
}
},
{ "$lookup": { "from": "profile_event", "localField": "lifeband_event_id", "foreignField": "_id", "as": "lifeband" } },
{
"$project": {
"event_type": 1,
"profile_id": 1,
"event_occurence": 1,
"lifeband": { "$arrayElemAt": ["$lifeband", 0] },
"trigger_status": 1
}
},
{
"$addFields": {
"lifeband_last_modified_date": "$lifeband.last_modified_date",
"lifeband_last_modified_days": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$lifeband.last_modified_date"] }, 86400000] } }
}
},
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_id", "foreignField": "profile_id", "as": "lifeband_info" } },
{
"$project": {
"event_type": 1,
"profile_id": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"lifeband_last_modified_days": 1,
"lifeband_last_modified_date": 1,
"lifeband": 1,
"trigger_status": 1, "lifeband_info": { "$arrayElemAt": ["$lifeband_info", 0] }
}
},
{
"$addFields": {
"lifeband_info_event_trigger_date": "$lifeband_info.created_date",
"lifeband_info_event_trigger_days": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$lifeband_info.created_date"] }, 86400000] } }
}
},
{
"$project": {
"event_type": 1,
"profile_id": 1,
"event_trigger_date": { "$cond": { "if": { "$eq": ["$lifeband_last_modified_date", null] }, "then": "$lifeband_info_event_trigger_date", "else": "$lifeband_last_modified_date" } },
"event_occurence": 1,
"trigger_status": 1,
"lifeband_info_event_trigger_date": 1,
"lifeband_info_event_trigger_days": 1,
"lifeband_last_modified_days": 1,
"lifeband_last_modified_date": 1,
"category_value": { "$cond": { "if": { "$eq": ["$lifeband_last_modified_days", null] }, "then": "$lifeband_info_event_trigger_days", "else": "$lifeband_last_modified_days" } }
}
},
{ "$unset": ["lifeband_last_modified_days", "lifeband_info_event_trigger_days", "lifeband_last_modified_date", "lifeband_info_event_trigger_date"] }]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$match": { "event_type": { "$eq": "HEALTH_FACTORS_NX" } } },
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{
"$addFields": {
"category_value": { "$trunc": { "$divide": [{ "$subtract": ["$$NOW", "$event_trigger_date"] }, 86400000] } }
}
},
{ "$unset": ["last_modified_date", "notification_type", "progress_status"] }]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_id", "foreignField": "profile_id", "as": "lifeband_info" } },
{
"$project": {
"profile_id": 1,
"lifeband_info": { "$arrayElemAt": ["$lifeband_info", 0] }
}
},
{ "$addFields": { "category_value": { "$abs": { "$subtract": [{ "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.max" }, { "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.min" }] } } } },
{
"$project": {
"profile_id": 1,
"category_value": 1
}
},
{ "$lookup": { "from": "profile_event", "localField": "profile_id", "foreignField": "profile_id", "as": "profile_event_data" } },
{
"$project": {
"profile_id": 1,
"category_value": 1,
"event_type_set": { "$concatArrays": ["$profile_event_data.event_type"] }
}
},
{
"$project": {
"profile_id": 1,
"category_value": 1,
"event_exists": { "$in": ["JUVBAND_ACCURACY_LOW_NX", "$event_type_set"] }
}
},
{ "$match": { "event_exists": { "$ne": true } } },
{
"$addFields": {
"_id": { "$concat": ["JUVBAND_ACCURACY_LOW_0X:", "$profile_id"] },
"event_type": "JUVBAND_ACCURACY_LOW_NX",
"event_trigger_date": "$$NOW",
"event_occurence": 0,
"trigger_status": "SILENT"
}
},
{ "$unset": "event_exists" }]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$match": { "event_type": { "$eq": "JUVBAND_ACCURACY_LOW_NX" } } },
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" },
{ "$replaceRoot": { "newRoot": "$data" } },
{ "$lookup": { "from": "profile", "localField": "profile_id", "foreignField": "_id", "as": "profile_data" } },
{ "$unwind": { "path": "$profile_data" } },
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_data.profile_recommendation_info_id", "foreignField": "_id", "as": "lifeband_info" } },
{ "$unwind": { "path": "$lifeband_info" } },
{ "$addFields": { "category_value": { "$abs": { "$subtract": [{ "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.max" }, { "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.min" }] } } } },
{ "$unset": ["last_modified_data", "notification_type", "progress_status", "lifeband_info", "profile_data"] }]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" }, { "$replaceRoot": { "newRoot": "$data" } },
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_id", "foreignField": "profile_id", "as": "lifeband_info" } },
{
"$project": {
"profile_id": 1,
"lifeband_info": { "$arrayElemAt": ["$lifeband_info", 0] }
}
},
{ "$addFields": { "category_value": { "$abs": { "$subtract": [{ "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.max" }, { "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.min" }] } } } },
{
"$project": {
"profile_id": 1,
"category_value": 1
}
},
{ "$lookup": { "from": "profile_event", "localField": "profile_id", "foreignField": "profile_id", "as": "profile_event_data" } },
{
"$project": {
"profile_id": 1, "category_value": 1,
"event_type_set": { "$concatArrays": ["$profile_event_data.event_type"] }
}
},
{
"$project": {
"profile_id": 1, "category_value": 1,
"event_exists": { "$in": ["JUVBAND_ACCURACY_MEDIUM_NX", "$event_type_set"] }
}
},
{ "$match": { "event_exists": { "$ne": true } } },
{
"$addFields": {
"_id": { "$concat": ["JUVBAND_ACCURACY_MEDIUM_0X:", "$profile_id"] },
"event_type": "JUVBAND_ACCURACY_MEDIUM_NX", "event_trigger_date": "$$NOW", "event_occurence": 0, "trigger_status": "SILENT"
}
},
{ "$unset": "event_exists" }]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$match": { "event_type": { "$eq": "JUVBAND_ACCURACY_MEDIUM_NX" } } },
{ "$sort": { "event_trigger_date": -1 } }, 
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" }, { "$replaceRoot": { "newRoot": "$data" } },
{ "$lookup": { "from": "profile", "localField": "profile_id", "foreignField": "_id", "as": "profile_data" } },
{ "$unwind": { "path": "$profile_data" } },
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_data.profile_recommendation_info_id", "foreignField": "_id", "as": "lifeband_info" } },
{ "$unwind": { "path": "$lifeband_info" } },
{
"$addFields": {
"category_value": { "$abs": { "$subtract": [{ "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.max" }, { "$toDouble": "$lifeband_info.output.lifeband.accuracyLevel.min" }] } }
}
},
{ "$unset": ["last_modified_date", "notification_type", "progress_status", "lifeband_info", "profile_data", "accuracy_level"] }
]
}
},
{
"$unionWith": {
"coll": "profile_event", "pipeline": [
{ "$sort": { "event_trigger_date": -1 } },
{ "$group": { "_id": { "profile_id": "$profile_id" }, "data": { "$first": "$$ROOT" } } },
{ "$unset": "_id" }, { "$replaceRoot": { "newRoot": "$data" } },
{ "$addFields": { "profile_strength_id": { "$concat": ["profile_strength:", "$profile_id"] } } },
{ "$lookup": { "from": "profile_event", "localField": "profile_strength_id", "foreignField": "_id", "as": "profile_strength_info" } },
{ "$unwind": { "path": "$profile_strength_info" } }, { "$addFields": { "category_value": { "$toInt": "$profile_strength_info.progress_status" } } },
{ "$project": { "profile_id": 1, "category_value": 1 } },
{ "$lookup": { "from": "profile_event", "localField": "profile_id", "foreignField": "profile_id", "as": "profile_event_data" } },
{
"$project": {
"profile_id": 1,
"category_value": 1,
"event_type_set": { "$concatArrays": ["$profile_event_data.event_type"] }
}
},
{
"$project": {
"profile_id": 1,
"category_value": 1,
"event_exists": { "$in": ["PROFILE_MEDIUM_NX", "$event_type_set"] }
}
},
{ "$match": { "event_exists": { "$ne": true } } },
{
"$addFields": {
"_id": { "$concat": ["PROFILE_MEDIUM_0X:", "$profile_id"] },
"event_type": "PROFILE_MEDIUM_NX",
"event_occurence": 0,
"trigger_status": "SILENT"
}
},
{ "$unset": "event_exists" },
{
"$project": {
"event_type": 1,
"profile_id": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"trigger_status": 1,
"category_value": { "$cond": { "if": { "$eq": ["$category_value", null] }, "then": 0, "else": "$category_value" } }
}
},
{ "$lookup": { "from": "profile_lifeband_info", "localField": "profile_id", "foreignField": "profile_id", "as": "lifeband_info" } },
{
"$project": {
"event_type": 1,
"profile_id": 1,
"event_trigger_date": 1,
"event_occurence": 1,
"lifeband": 1,
"trigger_status": 1,
"category_value": 1,
"lifeband_info": { "$arrayElemAt": ["$lifeband_info", 0] }
}
},
{
"$addFields": {
"event_trigger_date": "$lifeband_info.created_date"
}
},
{ "$unset": "lifeband_info" }
]
}
}
])

相关内容

  • 没有找到相关文章

最新更新