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

Ensure we do not do a redundant $sort by search score during $rankFusion.

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration

      I'm not sure there is much work here, depending on how the implementation goes, but there is some risk that in order to compute the rank for a $search pipeline we will need to generate this pipeline:

      db.example.aggregate([
        {$search: {/* query*}},
        {$sort: {score: {$meta: "searchScore"}}},
        {$_internalSetWindowFields: {output: {rank: {$rank: {}}}}
      ])
      

      The second $sort doesn't do anything. It might be generated as part of $rankFusion's desugaring, since we need to specify a sortBy to $setWindowFields in order to compute the rank. Note that SERVER-91281 might mean that we don't need to generate this kind of pipeline, in which case this ticket is more of a no-op and can be tracked on the backlog as a request to optimize out a $sort in this scenario, if it comes up for a user who is using $setWindowFields.

            Assignee:
            Unassigned Unassigned
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: