Skip to content

MongoCommandException while using of $all in aggregation  #3762

Open
@antdementyev

Description

@antdementyev

Structure of documents:

{
  id: ObjectId("5ef1cd704b35c6d6698f2050")
  date: 2021-12-15T11:03:00.000+00:00
  priorityList: Array
    0: "any-String-id-here"
    1: ...
}

Using of $all in Aggregation:

TypedAggregation<MyDocument> aggregation = newAggregation(MyDocument.class,
  project("id")
    .and("isInList").applyCondition(ConditionalOperators
        .when(Criteria.where("priorityList").all("here-my-string-to-check"))
        .then(1)
        .otherwise(0)),
  sort(Sort.by(
    Sort.Order.desc("isInList"),
    Sort.Order.desc("date"))));
mongoTemplate.aggregate(aggregation, "my-collection-name", String.class);

produces

com.mongodb.MongoCommandException: 
Command failed with error 168 (InvalidPipelineOperator): 'Invalid $project ::
caused by :: Unrecognized expression '$all''

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions