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

$indexOfArray does not work with duplicate values in array

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.14, 5.3.0, 5.0.7, 4.2.20, 5.2.2
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v5.2, v5.0, v4.4, v4.2, v4.0
    • Hide
      db.test.insertOne({
        number: 234
      })
      
      db.test.aggregate([
        { $addFields: {
          test: {
            $indexOfArray: [[123, 123, 234], "$number"]
          }
        } },
      ])
      
      Show
      db.test.insertOne({ number: 234 }) db.test.aggregate([ { $addFields: { test: { $indexOfArray: [[123, 123, 234], "$number" ] } } }, ])
    • QO 2022-01-10

      When array with duplicit values is supplied as a first argument to $indexOfArray, it starts returning `-1` when searching for subsequent values.

            Assignee:
            steve.tarzia@mongodb.com Steve Tarzia
            Reporter:
            cyner@overflow.cz Jan Votava
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: