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

Regex negative look-ahead assertion do not work on nested collections

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.5
    • Component/s: Querying
    • None
    • OS X
    • Hide

      Do a negative look-ahead $regex search collection with nested collection. I've only tried this on version 2.6.5 on OSX 10.10.3

      Show
      Do a negative look-ahead $regex search collection with nested collection. I've only tried this on version 2.6.5 on OSX 10.10.3
    • Query 10 (02/22/16)

      I have a collection with a simple array of values and also with a nested collection. If I do a negative look-ahead $regex search on the documents with everything works fine but if I do the same search on documents with a nested collection it doesn't work. For example:

      sample list collection
      {
        "_id": ObjectId("54deb2ed4e5018cf1c737b8d"),
        "values": [ "apples", "peaches", "bananas" ]
      }
      {
        "_id": ObjectId("54df5b40f546cf4c25013190"),
        "values": ["grapes", "oranges" ]
      }
      
      db.sampleList.count( { 'values':{$regex:"^(?<!appl).*", $options:'i '} });  // 1
      
      sample nested collection
      {
        "_id": ObjectId("54e28b6caaadddb844d1f40a"),
        "values": [
          {
            "value": " apple",
            "label": "Choice 1"
          },
          {
            "value": "peach",
            "label": "Choice 2"
          },
          {
            "value": "banana",
            "label": "Choice 3"
          },
          {
            "value": "orange",
            "label": "Choice 4"
          }
        ]
      }
      {
        "_id": ObjectId("54eb580ee163c16b23145536"),
        "values": [
          {
            "value": "orange",
            "label": "Choice 1"
          },
          {
            "value": "banana",
            "label": "Choice 2"
          },
          {
            "value": "peaches",
            "label": "Choice 3"
          },
          {
            "value": "grapes",
            "label": "Choice 4"
          }
        ]
      
      db.sampleList.count( { 'values.value':{$regex:"^(?<!appl).*", $options:'i '} });  // 2
      

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            jonah@surveyplanet.com Jonah Werre
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: