Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-70691

Equality-indexed field cannot use $in in aggregation.

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Optimization
    • ALL
    • Hide

      Schema:

      {
          encryptedFields: {
              "fields": [
                  {
                      path: "age",
                      bsonType: "int",
                      queries: {queryType: "range", min: NumberInt(0), max: NumberInt(255), sparsity: 1}
                  },
                  {path: "zipcode", bsonType: "string", "queries": {"queryType": "equality"}},
              ]
          }
      }
      

      Query:

      {
          $and: [
              {$gte: ["$age", NumberInt(22)]},
              {$lt: ["$age", NumberInt(25)]},
              {$in: ["$zipcode", ["098765", "ABCDE", "1257"]]}
          ]
      }
      
      Show
      Schema: { encryptedFields: { "fields" : [ { path: "age" , bsonType: " int " , queries: {queryType: "range" , min: NumberInt(0), max: NumberInt(255), sparsity: 1} }, {path: "zipcode" , bsonType: "string" , "queries" : { "queryType" : "equality" }}, ] } } Query: { $and: [ {$gte: [ "$age" , NumberInt(22)]}, {$lt: [ "$age" , NumberInt(25)]}, {$in: [ "$zipcode" , [ "098765" , "ABCDE" , "1257" ]]} ] }
    • QO 2022-10-31

      Query analysis seems overly eager and errors when $in is used, even with an equality index, failing with the error: "ExpressionIn with RangeIndex not yet supported". The range intender should check if the field being operated on is indexed with range before asserting.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            davis.haupt@mongodb.com Davis Haupt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: