You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by heregear <er...@heregear.com> on 2014/05/16 03:33:48 UTC

MongoDB aggregation $out operator can it work in Camel?

Is there a way to make an aggregation pipeline create the collection with the
$out operator in Camel?

This does not work:
<setBody><simple>
   {$match: { myfield: "myvalue" } } ,
   {$group: { _id: "$myfield"}},
   {$out : "my_other_collection"}
</simple></setBody>

This works fine, but I have to convert to a java.lang.Object[] and then do
another route to insert the data:
<setBody><simple>
{$match: { myfield: "myvalue" } } ,
{$group: { _id: "$myfield"}}
</simple></setBody>

If I can get the $out operator working in an aggregation pipeline this will
save a round-trip to the server from the mongod engine and greatly increase
performance...

Setup:  latest version of Camel, latest version of Mongo, routes are in
Spring DSL XML.

Thanks in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/MongoDB-aggregation-out-operator-can-it-work-in-Camel-tp5751190.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: MongoDB aggregation $out operator can it work in Camel?

Posted by heregear <er...@heregear.com>.
Another possible bug:  it appears that camel mongodb component does not
support the $push operator for aggregations.

The following does not work, it should aggregate (group) on my_designator,
and $push all occurrences of contributor_ref into an array for each instance
of my_designator into a new array named contributor_refs. As a matter of
fact, when it sees this, it's not aggregating (grouping) at all:

{$match: { data_type: "WHATEVER" }},
{$group: { _id : "$my_designator", contributor_refs: {
$push:"$contributor_ref" }}},
   					{$project : { _id : 0,
                 	my_designator : "$_id",
                 	contributor_refs : "$contributor_refs"
                	}}


This works fine in the mongo shell, FYI.

So:  when you added support for the aggregation framework to Camel, did you
unit test each operator?  Can you tell us what you didn't unit test within
the aggregation framework so that we can be prepared for other things that
may not work?

Thanks in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/MongoDB-aggregation-out-operator-can-it-work-in-Camel-tp5751190p5751257.html
Sent from the Camel - Users mailing list archive at Nabble.com.