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

$match with an array and the use of a function fails to match

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

      See attached data file and run JS file against the collection with the loaded data.

      Show
      See attached data file and run JS file against the collection with the loaded data.
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Found an issue with how a $match stage works with a function as part of the query.  It occurs when performing a search within an array.  There is an attached sample data file and a sample JS file for execution. The first and third aggregations work as expected; however the second fails.

      It is assumed that comparing elements in an array against a literal (ie 2) should return the same as comparing elements in an array against a MULTIPLE(2, 1) function.

      This pattern has been reduced down to the simplest form versus how we discovered this.  Our use case was matching into an array of objects post a $lookup stage to find root records that match a condition of documents in the $lookup array.

      This was also proven to work against an array when $group was used.

      It seems to not be tied to integers, numerics, dates, either.  Simple the use of a function in the match seems to be the issue.

      The JS file is commented with notes and assumptions about expected behavior.

      Thank you

        1. Screenshot 2024-12-19 at 4.49.51 PM.png
          85 kB
          Tyson Henry
        2. match.js
          2 kB
          Tyson Henry
        3. test.csv
          0.1 kB
          Tyson Henry

            Assignee:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            tyson.henry@burstiq.com Tyson Henry
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: