Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5106

AndFilter merging filters into single $expr

    • Type: Icon: Question Question
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Builders
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      We have multiple  filters with $expr in a list, and we are passing this list in to method
      AggregateIterable<TDocument> aggregate(List<? extends Bson> pipeline); of class MongoCollection.  
       
      If we have and filter in it and if you see com.mongodb.client.model.Filters.AndFilter it will l combine all the condition into one condition.
       
      Value passed as :

       

      {"$expr": {"$eq": [ {"$strcasecmp": ["$CreatedBy", "tenant21"]}, 0] }}
      
      {"$expr": {"$in": [ {"$toLower": "$a"}, ["a"]] }}
      

       
      Command executed:

      {"$expr": {"$eq": [ {"$strcasecmp": ["$CreatedBy", "tenant21"]}, 0], "$in": [{"$toLower": "$a"}, ["a"]]}}
      

      If you see above it will combine two $expr into single $expr and while executing it will fail saying, $expr can only contain single object.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            nitulkukadia Nitul Kukadia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: