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

allow query option to return found documents enclosed in a "meta" document containing array offset information

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Query Execution

    Description

      if i have a collection of documents like:

      { name: 'fred', children: [

      { name: 'bill', age: 10 }

      ,

      { name: 'bob', age: 20 }

      ,

      { name: 'ed', age: 30 }

      ] }

      and i want to operate on all children whose age is greater than 10, i don't believe there is a direct way to accomplish this.

      i'm coming at this from the context of this jira entry: https://jira.mongodb.org/browse/SERVER-3347

      i believe in the multi-geo case the document is returned once for each hit, which implies that multiple elements of an array met the search criteria.

      in the multi-non-geo case the document is returned only once, i think it would be best to remain consistent, and in SERVER-3347 i suggest returning the document only once (after all returning the same document multiple times doesn't add much value),
      but i allude to a "wrapper" document containing "meta" information on which elements of the array met the uery criteria.

      i think the same pattern may be applicable to the multi-non-geo case, in a way to address the case in between the $ position operator and the multi (apply to all) mechanism.

      so if there was a way to return something like:

      {
      hits: [

      {field: "children.age", index: 1 }

      ,

      {field: "children.age", index: 2 }

      ],
      document:

      { // the actual document }


      }

      i think it would give the caller enough information to operate on those elements of the array that were of interest...?

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            tony_k tony kerz
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: