Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3 RC1
    • Component/s: Core
    • Labels:
      None
    • Sprint:
      Babbage - RC1 - Stage Two

      Description

      Mongo 2.2 has some new aggregation framework features that we could add query/criteria support for.

      http://docs.mongodb.org/manual/applications/aggregation/#overview

        Activity

        Hide
        Ilya Sorokoumov added a comment -

        BTW: This task would require augmenting of org.springframework.data.mongodb.core.query.Criteria.
        The problem is that for some stages of aggregation framework some criteria have slightly different semantics.
        E.g. current $gte implementation for basic mongo query looks like this:
        public Criteria gte(Object o)

        { criteria.put("$gte", o); return this; }

        But for Aggregation framework it would look like this:
        public static DBObject asGreaterThanEquals(Object object1, Object object2)

        { BasicDBList gteArgs = new BasicDBList(); gteArgs.add(object1); gteArgs.add(object2); BasicDBObject gte = new BasicDBObject("$gte", gteArgs); return gte; }

        Because on some stages you are allowed to compare 2 fields.

        Show
        Ilya Sorokoumov added a comment - BTW: This task would require augmenting of org.springframework.data.mongodb.core.query.Criteria. The problem is that for some stages of aggregation framework some criteria have slightly different semantics. E.g. current $gte implementation for basic mongo query looks like this: public Criteria gte(Object o) { criteria.put("$gte", o); return this; } But for Aggregation framework it would look like this: public static DBObject asGreaterThanEquals(Object object1, Object object2) { BasicDBList gteArgs = new BasicDBList(); gteArgs.add(object1); gteArgs.add(object2); BasicDBObject gte = new BasicDBObject("$gte", gteArgs); return gte; } Because on some stages you are allowed to compare 2 fields.
        Hide
        Tobias Trelle added a comment -

        If looking at the Mongo shell (https://gist.github.com/3313969#file-04_aggregation-js) and the Java driver API (https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/DBCollection.java) ...

        public AggregationOutput aggregate( DBObject firstOp, DBObject ... additionalOps){

        ... I'm not sure if the aggregation parameters will fit to the Criteria class. I'd like to propose to add a method to the MongoTemplate similar to this:

        public <T> AggregationResult<T> aggreate(AggregationPipeline pipeline, Class<T> entityClass)

        {...}

        where AggregationPipeline has at least a constructor which takes a list of JSON string and maybe a version with a more abstract approach similiar to the Criteria class.

        What do you think?

        Show
        Tobias Trelle added a comment - If looking at the Mongo shell ( https://gist.github.com/3313969#file-04_aggregation-js ) and the Java driver API ( https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/DBCollection.java ) ... public AggregationOutput aggregate( DBObject firstOp, DBObject ... additionalOps){ ... I'm not sure if the aggregation parameters will fit to the Criteria class. I'd like to propose to add a method to the MongoTemplate similar to this: public <T> AggregationResult<T> aggreate(AggregationPipeline pipeline, Class<T> entityClass) {...} where AggregationPipeline has at least a constructor which takes a list of JSON string and maybe a version with a more abstract approach similiar to the Criteria class. What do you think?
        Show
        Oliver Gierke added a comment - Pull request by Tobias Trelle : https://github.com/SpringSource/spring-data-mongodb/pull/25
        Hide
        Oliver Gierke added a comment -
        Show
        Oliver Gierke added a comment - Merged contribution into feature branch at https://github.com/SpringSource/spring-data-mongodb/tree/DATAMONGO-586 . See https://github.com/SpringSource/spring-data-mongodb/pull/25 for further discussion.

          People

          • Assignee:
            Thomas Darimont
            Reporter:
            Thomas Risberg
          • Votes:
            10 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Agile