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

$indexOfArray does not work with duplicate values in array

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.4.14, 5.3.0, 5.0.7, 5.2.2, 4.2.20
    • 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

    Description

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: