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

Recursive query of nested document

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None

      I have a collection that has 'nested' documents. For example, a document can have the following structure:

      {
          "condition": {
              "parameter": {
                  "type": "person"
              }
          }
      }
      

      as well as:

      {
          "condition": {
              "conditions": [
                  {
                      "conditions": [
                          {
                              "parameter": {
                                  "type": "A"
                              }
                          },
                          {
                              "parameter": {
                                  "type": "B"
                              }
                          }
                      ]
                  },
                  {
                      "parameter": {
                          "type": "C"
                      }
                  }
              ]
          }
      }
      

      Meaning, each condition sub-document can have multiple conditions within itself.

      Now, I'd want to make a 'recursive' query on the type field of each condition, something like ('..' representing the recursion):

      {
          "$or": [
              {"condition.type": "person"},
              {"condition..conditions.type": "person"}
          ]
      }
      

      From what I've seen there's no way to do this yet, but it would be really awesome.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            LuisTAC Luis Torres Aguiar da Costa
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: