The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
How to properly use the mongo update operator?
I wanted to use the mongo update operator for some simple process, but it keeps stating there is something wrong with the JSON format I provide, even in the simplest format possible. My assumption is therefore that I must have misunderstood how it works, but there are no examples available.
This is an extreme simple example that fails, can someone tell me how I need to use it properly?
<?xml version="1.0" encoding="UTF-8"?><process version="8.1.003">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="8.1.003" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document (2)" width="90" x="179" y="136">
<parameter key="text" value="{"key" : "value"}"/>
</operator>
<operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="Create Document (3)" width="90" x="179" y="34">
<parameter key="text" value="{"_id" : "dummy"}"/>
</operator>
<operator activated="true" class="nosql:mongodb_document_updater" compatibility="7.6.000" expanded="true" height="82" name="Update MongoDB (3)" width="90" x="380" y="34">
<parameter key="mongodb_instance" value="my_mongo_db"/>
<parameter key="collection" value="my_collection"/>
<parameter key="update_individual_fields" value="false"/>
<parameter key="insert_unmatched_documents_(upsert)" value="true"/>
</operator>
<connect from_op="Create Document (2)" from_port="output" to_op="Update MongoDB (3)" to_port="update"/>
<connect from_op="Create Document (3)" from_port="output" to_op="Update MongoDB (3)" to_port="criteria"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
</process>
</operator>
</process>
Note that I have no problem using the other operators, in general I use the execute mongoDB command to perform updates but I'm puzzled with what goes wrong with this one.
0
Answers
Seems I need to use explicit statements like $set to make it work, so it may be more of a semantic statement.
Would be nice anyway to learn a bit more about the options / limitations of the mongo operators to avoid trial and error workflows.