Query Your Data

You can type MongoDB filter documents into the query bar to display only documents which match the specified criteria. To learn more about querying documents, see Query Documents in the MongoDB manual.

Set Query Filter

  1. In the Filter field, enter a filter document. You can use all of the MongoDB query operators except the $text and $expr operators.


    The following filter only returns documents which have a Country value of Brazil:

    { Country: "Brazil" }
  2. Click Find to run the query and view the updated results.


For query result sets larger than 1000 documents, Compass shows a sampling of the results. Otherwise, Compass shows the entire result set.

For details on sampling, see the FAQ.

Supported Data Types in the Query Bar

The Compass Filter supports using the mongo shell mode representation of the MongoDB Extended JSON BSON data types.


The following filter returns documents where start_date is greater than than the BSON Date 2017-05-01:

{ "start_date": {$gt: new Date('2017-05-01')} }

By specifying the Date type in both start_date and the $gt comparison operator, Compass performs the greater than comparison chronologically, returning documents with start_date later than 2017-05-01.

Without the Date type specification, Compass compares the start_dates as strings lexicographically, instead of comparing the values chronologically.

Clear the Query

To clear the query bar and the results of the query, click Reset.

How Does the Compass Query Compare to MongoDB and SQL Queries?

$filter corresponds to the WHERE clause in a SQL SELECT statement.


You have 3,235 articles. You would like to see all articles that Joe Bloggs wrote.

Compass Filter Option
{ author : { $eq : "Joe Bloggs" } }
MongoDB Aggregation
  { $filter : { author : { $eq : "Joe Bloggs" } } }
SELECT * FROM article
WHERE author = "Joe Bloggs";