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.
クエリフィルターの設定
Atlas で、プロジェクトの Data Explorer ページに移動します。
まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。
まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。
サイドバーで、 Database見出しの下のData Explorerをクリックします。
The Data Explorer displays.
重要: クラスターの名前をクリックしてCluster サイドバーを開き、Data Explorer 見出しの下のShortcuts をクリックすることもできます。
クエリフィルターを設定します。
コレクションを選択します。
In the Filter field, enter a filter document between the curly braces. You can use all the MongoDB query operators except the
$textand$exproperators.例
次のフィルターは、
titleの値がJurassic Parkであるドキュメントを返します。{ "title": "Jurassic Park" } [Find] をクリックしてクエリを実行し、更新された結果を表示します。

例
このページでは、小さなデータセットの例を使用しています。サンプル データを MongoDB 配置にインポートするには、次の手順を実行します。
以下のドキュメントをクリップボードにコピーします。
[ { "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }, { "email": "no_name@fake-mail.com", "version": 4, "scores": [ 90, 90, 70 ], "dateCreated": { "$date": "2001-04-15" } }, { "name": "Greg Powell", "email": "greg_powell@fake-mail.com", "version": 1, "scores": [ 65, 75, 80 ], "dateCreated": { "$date": "1999-02-10" } } ] Atlas では、左側のナビゲーション パネルを使用して、データをインポートするデータベースとコレクションを選択します。
[Documents] タブをクリックします。
[Add Data] をクリックし、[Insert Document] を選択します。
View を JSON(
{})に設定します。クリップボードから JSON ドキュメントをモーダルに貼り付けます。
[Insert] をクリックします。
注意
If you do not have a MongoDB deployment or if you want to query a larger sample data set, see Sample Data for Atlas Clusters for instructions on creating a free cluster with sample data. The following example queries filter the sample documents provided on this page.
1 つの条件による一致
次のクエリフィルターは、name の値が "Andrea Le" であるすべてのドキュメントを検索します。
{ name: "Andrea Le" }
このクエリは、次のドキュメントを返します。
{ "_id": { "$oid": "5e349915cebae490877d561d" }, "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }
複数条件による一致($and)
次のクエリフィルターは、scores 配列に値 75 が含まれ、name が Greg Powell であるすべてのドキュメントを検索します。
{ $and: [ { scores: 75, name: "Greg Powell" } ] }
このクエリは、次のドキュメントを返します。
{ "_id": { "$oid":"5a9427648b0beebeb69579cf" }, "name": "Greg Powell", "email": "greg_powell@fake-mail.com", "version": 1, "scores": [ 65, 75, 80 ], "dateCreated": { "$date": "1999-02-10" } }
複数の可能な条件による一致($or)
The following query filter uses the $or operator to find documents where version is 4, or name is Andrea Le:
{ $or: [ { version: 4 }, { name: "Andrea Le" } ] }
このクエリでは次のドキュメントが返されます。
[ { "_id": { "$oid": "5e349915cebae490877d561d" }, "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }, { "_id": { "$oid":"5e349915cebae490877d561e" }, "email": "no_name@fake-mail.com", "version": 4, "scores": [ 90, 90, 70 ], "dateCreated": { "$date": "2001-04-15" } } ]
除外による一致($not)
The following query filter uses the $not operator to find all documents where the value of the name field is not equal to "Andrea Le", or the name field does not exist:
{ name: { $not: { $eq: "Andrea Le" } } }
このクエリでは次のドキュメントが返されます。
[ { "_id": { "$oid":"5e349915cebae490877d561e" }, "email": "no_name@fake-mail.com", "version": 4, "scores": [ 90, 90, 70 ], "dateCreated": { "$date": "2001-04-15" } }, { "_id": { "$oid":"5a9427648b0beebeb69579cf" }, "name": "Greg Powell", "email": "greg_powell@fake-mail.com", "version": 1, "scores": [ 65, 75, 80 ], "dateCreated": { "$date": "1999-02-10" } } ]
Tip
For a complete list of logical query operators, see Logical Query Operators.
比較演算子による一致
The following query filter uses the $lte operator to find all documents where version is less than or equal to 4:
{ version: { $lte: 4 } }
このクエリでは次のドキュメントが返されます。
[ { "_id": { "$oid":"5e349915cebae490877d561e" }, "email": "no_name@fake-mail.com", "version": 4, "scores": [ 90, 90, 70 ], "dateCreated": { "$date": "2001-04-15" } }, { "_id": { "$oid":"5a9427648b0beebeb69579cf" }, "name": "Greg Powell", "email": "greg_powell@fake-mail.com", "version": 1, "scores": [ 65, 75, 80 ], "dateCreated": { "$date": "1999-02-10" } } ]
Tip
比較演算子の全リストについては、「比較クエリ演算子」を参照してください。
日付による一致
The following query filter uses the $gt operator and Date() method to find all documents where the dateCreated field value is later than June 22nd, 2000:
{ dateCreated: { $gt: new Date('2000-06-22') } }
このクエリでは次のドキュメントが返されます。
[ { "_id": { "$oid": "5e349915cebae490877d561d" }, "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }, { "_id": { "$oid": "5e349915cebae490877d561e" }, "email": "no_name@fake-mail.com", "version": 4, "scores": [ 90, 90, 70 ], "dateCreated": { "$date": "2001-04-15" } } ]
配列条件による一致
The following query filter uses the $elemMatch operator to find all documents where at least one value in the scores array is greater than 80 and less than 90:
{ scores: { $elemMatch: { $gt: 80, $lt: 90 } } }
scores 配列の値の 1 つが 85 であるため、クエリは次のドキュメントを返します。
{ "_id": { "$oid": "5e349915cebae490877d561d" }, "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }
その他のクエリの例については、MongoDB マニュアルの「クエリ ドキュメント」を参照してください。
Substring による一致
The following query filter uses the $regex operator to find all documents where the value of email includes the term "andrea_le":
{ email: { $regex: "andrea_le" } }
このクエリは、次のドキュメントを返します。
{ "_id": { "$oid": "5e349915cebae490877d561d" }, "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }
埋め込みフィールドによる一致
次のクエリフィルターで、school.name サブフィールドが「Northwestern」であるドキュメントが検索されます。
{ "school.name": "Northwestern" }
このクエリは、次のドキュメントを返します。
{ "_id": { "$oid": "5e349915cebae490877d561d" }, "name": "Andrea Le", "email": "andrea_le@fake-mail.com", "school": { "name": "Northwestern" }, "version": 5, "scores": [ 85, 95, 75 ], "dateCreated": { "$date": "2003-03-26" } }
その他のクエリの例については、MongoDB マニュアルの「クエリ ドキュメント」を参照してください。
クエリ バーでサポートされているデータ型
The Atlas Filter supports using the mongosh representation of the MongoDB Extended JSON BSON data types.
例
次のフィルターは、start_date が BSON の Date 2017-05-01 より後のドキュメントを返します。
{ "start_date": {$gt: new Date('2017-05-01')} }
start_date と $gt 比較演算子の両方に Date 型を指定すると、Atlas は greater than 比較を時系列で実行し、2017-05-01 より後の start_date を持つドキュメントを返します。
Date 型指定がない場合、Atlas は 、値を時系列で比較するのではなく 、start_dates を文字列として 辞書編集順 に比較します。
クエリをクリア
クエリ バーとクエリの結果を消去するには、[Reset] をクリックします。
Atlas クエリとMongoDBクエリおよびSQLクエリの比較
$filter corresponds to the WHERE clause in a SQL SELECT statement.
例
3,235 件の記事があります。Joe Bloggs が書いた記事をすべて見ようとしています。
- Atlas フィルター オプション
{ author : { $eq : "Joe Bloggs" } } - MongoDB 集計
db.article.aggregate( { $match: { "author": "Joe Bloggs" } } ) - SQL
SELECT * FROM article WHERE author = "Joe Bloggs";