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

multikeys Index unbounded with $elemMatch

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL

      I found many closed issues about multikeys index bounds but I can't find an opened one for the 3.6.13

      Regarding this index :

       

      {
          "activities.metadatas.joinValue" : 1,
          "activities.metadatas.joinStart" : 1,
          "activities.metadatas.joinEnd" : 1
      }
      

      And this query :

       

       

      {'activities.metadatas': {'$elemMatch':{
          'joinValue':'4559157', 
          "joinStart": { "$gte": ISODate("2019-10-29T10:29:24.860Z"), 
                         "$lt": ISODate("2019-10-29T10:29:26.870Z") }}}
      }
      

      Then the query planner uses the previous index with theses bounds :

       

       

      {
      	"activities.metadatas.joinValue": [
      		"[\"4559157\", \"4559157\"]"
      	],
      	"activities.metadatas.joinStart": [
      		"[new Date(1572344964860), new Date(1572344966870))"
      	],
      	"activities.metadatas.joinEnd": [
      		"[MinKey, MaxKey]"
      	]
      }
      

      ==> OK

      Now with this query variant

       

      {'activities':{'$elemMatch':{'metadatas': {'$elemMatch':{
      	'joinValue':'4559157','name': 'customer_id',
      	"joinStart": {
      		"$gte": ISODate("2019-10-29T10:29:24.860Z"),
      		"$lt": ISODate("2019-10-29T10:29:26.870Z")
      }}}}}}

      Then the bounds are :

       

       

      { 
      "activities.metadatas.joinValue": [ "[\"4559157\", \"4559157\"]" ], "activities.metadatas.joinStart": [ "[MinKey, MaxKey]" ], "activities.metadatas.joinEnd": [ "[MinKey, MaxKey]" ]
      }
      

      => timeout..

       

       

       

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            franck.lefebure@gmail.com FRANCK LEFEBURE
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: