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

Improve error message for $near in aggregation to suggest workarounds

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible

      Given the below description and comments, we've repurposed this ticket into a request to improve the error message for $near. In particular, we would like the error to include information about how a $near predicate implies a sort of the data as well, which you may not want/need. If you don't want/need the sort part, there are workarounds available such as using $geoWithin predicates. These aren't easy workarounds, so we'll likely want to link to a docs page or something like that.

      Original Description

      Currently to perform a non-aggregation geo query one would use the $near operator. This operator is not allowed in aggregation pipeline, even as the first stage, and instead the aggregation pipeline requires a $geoNear stage.

      The rejection of $near by the aggregation pipeline causes particular problems because the drivers presently implement the count operation as an aggregation pipeline. Applications run into a problem when:

      • They issue a find
      • In the find operation, they specify conditions which include $near
      • They want to count the results

      The driver in this case wraps the query into an aggregation pipeline which the server subsequently fails.

      This was reported in https://jira.mongodb.org/browse/MONGOID-5096.

            Assignee:
            maddie.zechar@mongodb.com Maddie Zechar
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: