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

JSON search if any other key present other than given

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Hi Team,
       
      Wanted to check if we are using the following query to serve the purpose is it valid? 

      Let's suppose I have two documents as given below.
      {
      "_id": ObjectID('123'),
      "test":

      { "a":1, "b":1 }

      },
      {
      "_id": ObjectID('456'),
      "test":

      { "a":1 }

      I wanted to identify if there are any other keys present in the test object other than
      "a", so I went for some solution and following worked for me.
       
      db.col.find({"test": {"$gt":

      {"a": 1}

      }})
       
      But I did not found any such case over the MongoDB official documentation to search on the JSON object, so should we consider it to use?
       
      This is useful as we can do the index on the test object, which will improve the query performance.

      Thanks.

            Assignee:
            Unassigned Unassigned
            Reporter:
            hitesh.baldaniya@contentstack.com Hitesh Baldaniya
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: