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

Improve error message for $near in aggregation to suggest workarounds

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              oleg.pudeyev Oleg Pudeyev
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated: