Class MongoDBAggregateProducer

  • All Implemented Interfaces:
    AdaptrisComponent, AdaptrisMessageProducer, AdaptrisMessageSender, AdaptrisMessageWorker, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator

    @ComponentProfile(summary="Executes aggregate MongoDB queries, results returned as JSON Array.",
                      tag="producer,mongodb",
                      recommended=MongoDBConnection.class)
    public class MongoDBAggregateProducer
    extends MongoDBRetrieveProducer
    Producer that executes aggregate MongoDB queries, results returned as JSON Array.

    Example Pipeline:
    Returns the count of stars

    Data:

         
         [
           { "name" : "Café Con Leche", "stars" : 3, "categories" : ["Bakery", "Coffee", "Pastries"] },
           { "name" : "Fred's", "stars" : 1, "categories" : ["Bakery", "Coffee", "Pastries"] }
         ]
         
       

    Query:

         
         [{ "$group" : { "_id" : "$stars", "count" : { "$sum" : 1 } } }]
         
       

    Result:

         
         [ { "_id" : "1", "count" : "1" }, { "_id" : "3", "count" : "1" } ]
         
       

    In the adapter configuration file this class is aliased as mongodb-aggregate-producer which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • MongoDBAggregateProducer

        public MongoDBAggregateProducer()
    • Method Detail

      • setPipeline

        public void setPipeline​(DataInputParameter<java.lang.String> pipeline)
      • getAllowDiskUse

        public java.lang.Boolean getAllowDiskUse()
      • setAllowDiskUse

        public void setAllowDiskUse​(java.lang.Boolean allowDiskUse)
      • getToCollection

        public java.lang.Boolean getToCollection()
      • setToCollection

        public void setToCollection​(java.lang.Boolean toCollection)