Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-32082

Force the ordering of the documents when running a $in query against MongoDB

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2021.x, 2023.x
    • Component/s: Core MongoDB

      Description

      According to MongoDB documentation the order set by $in clause is not always respected in the result.

      This can lead to response with a different order than the one submitted in an NXQL IN clause when the query has no sort option and performed against DBS (MongoDB) backend.

      So far there is no known bug related to this behavior, because code is explicitly using sort option when ordering is necessary.

      This is something that we need to keep in mind but no action is required before observing a real problem.

      Contrary to what was initially written, this cannot be the cause of a wrong ordered when using an Elastic search because when documents are fetched from DBS because they're post sorted to follow the elastic response ordering.

      --------

      Previous wrong description (for the record)

      Observed problem: Sometimes when a PP uses ES, the result order returned from ES does not match what is shown in the UI.

      1. The VcsFetcher is loading the docs ids returned by elastic from the backend using a NXQL query SELECT * from document WHERE ecm:uuid IN (<ordered list of ids>).
      2. It has been observed that running this NXQL query against MongoDB does not always return the documents in the order of the $in clause, as confirmed by this post https://stackoverflow.com/questions/22797768/does-mongodbs-in-clause-guarantee-order#22800784

      Expected behavior: Nuxeo should force the order of the documents by sorting them according to the order of the list of ids provided to the IN clause

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: