Searching by ObjectId on Mongo Compass Searching by ObjectId on Mongo Compass mongodb mongodb

Searching by ObjectId on Mongo Compass


UPDATE Newer versions of Compass now support querying ObjectId similar to how they would be queried via the mongo shell (the $oid syntax will not work in these newer versions):

{_id: ObjectId('58f8085dc1840e050034d98f')}

If you're using an older version before 1.10.x you, enter the following into the query box:

{"_id":{"$oid":"58f8085dc1840e050034d98f"}}

It's also worth pointing out that in the UI you can click on one of the _ids and it will auto-populate the query box with the query based on what you clicked. You can also shift+click on multiple fields to create compound (and-ed) query criteria, or you can click and drag to select a range.

Skip and Limit are support for versions >= 1.8.x does support skip and limit when browsing under the Documents tab. Click the "Options" button on the right side of the Query Bar. See the Query Bar docs for illustration and details.

The Schema tab only supports limit, as this will do a sampling of documents and skip doesn't really make sense in that context.

In order to click on the _ids you need to be on the Schema tab. If your _ids are of type ObjectId, the visualization of the distribution will appear as a date range and you can drag over one or more lines to populate the query based on _id. If your _ids are some other type, some portion of them will display individually and you can click, drag, or shift-click over them.


The current version of MongoDB Compass (1.10.5) no longer appears to support $oid, but it does work with a standard query: {"_id":ObjectId("5a028baa2dc80f2e26a8ed63")}


{"_id":ObjectId("5f8344e2a00ed7f6172a7184")}