[SERVER-56138] JSON search if any other key present other than given Created: 16/Apr/21  Updated: 16/Apr/21  Resolved: 16/Apr/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Blocker - P1
Reporter: Hitesh Baldaniya Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-56139 JSON based query to identify if there... Closed
Participants:

 Description   

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.



 Comments   
Comment by Eric Sedor [ 16/Apr/21 ]

Hi hitesh.baldaniya@contentstack.com,

The SERVER project is for bugs and feature suggestions for the MongoDB server. For this question we'd like to encourage you to start by asking our community for help by posting on the MongoDB Developer Community Forums.

If the discussion there leads you to suspect a bug in the MongoDB server, then we'd want to discuss here in the SERVER project.

Gratefully,
Eric

Generated at Thu Feb 08 05:38:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.