what if I got two different reduce and summary in ...
# ask-stanley-ai
c
what if I got two different reduce and summary in different script, which will be trigger?
c
AI generated answer (using internal Slack threads):
In a Map/Reduce script, the
summarize
stage should always execute, even if there is no output in the
reduce
stage. This is because the
summarize
stage is designed to provide a summary of the script's execution, regardless of the output of the
reduce
stage. If you have two different
reduce
and
summary
in different scripts, the one that will be triggered depends on the order of execution of the scripts. If the scripts are independent, they will execute based on their scheduling or triggering event. If one script is called within another (like a Map/Reduce script calling another Map/Reduce script at the summary stage), the called script's
reduce
and
summary
will execute after the calling script's stages. For example, you can create a task to call another Map/Reduce script in the
summary
stage like this:
Copy code
javascript
task.create({
    taskType: task.TaskType.MAP_REDUCE,
    scriptId: 'customscript1',
    deploymentId: 'customdeploy1'
}).submit();
To access the values returned from the
Reduce
stage in the
Summary
stage, you can use
reduceContext.write
and
summaryContext.output
. For instance, if you have journal entries created in the
Reduce
stage and you want to have a summary list of their IDs in the summary, you can write the IDs in the
Reduce
stage and then access them in the
Summary
stage. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832475066
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830399036
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824073911
Please provide your feedback on this answer.