AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

フィルターにおける正規表現

バージョン1.6の新機能。

1.6 以降、start APIincludeNamespaces では、excludeNamespaces Filtered Sync で使用される パラメータと パラメータのフィルタを構成するために、正規表現 を使用できるようになりました。

フィルタリングされた同期を使用するためにmongosyncのデータベースとコレクションを照合するには、正規表現を使用できます。

{
"databaseRegex": {
"pattern": "<string>",
"options": "<string>"
},
"collectionsRegex": {
"pattern": "<string>",
"options": "<string>"
}
}

The regular expression pattern you pass into a filter must follow the regex syntax supported by the MongoDB server.

Regular expressions in filter documents use options listed in the regex guide. options is a string of concatenated options. For example, to specify the i and s options, pass in "si" to options. The order of concatenated options does not matter.

フィルター ドキュメント内の正規表現では、次のフィールドが使用されます。

オプション
タイプ
説明

collectionsRegex

ドキュメント

フィルターで一致させるコレクションを指定します。

collectionsRegex.options

string

一致で使用する正規表現オプション。

collectionsRegex.pattern

string

一致する正規表現パターン。

databaseRegex

ドキュメント

フィルターを一致させるデータベースを指定します。

databaseRegex.options

string

一致で使用する正規表現オプション。

databaseRegex.pattern

string

一致する正規表現パターン。

これらのオプションは、 includeNamespacesexcludeNamespacesパラメーターの両方で使用できます。

正規表現を使用すると、複数のデータベースやコレクションを単一のパターンで一致させることができます。 複数の同じ名前のデータベースまたはコレクションを照合する場合は、個々のデータベースまたはコレクションのグループに対して一連のフィルターを作成するよりも正規表現を使用した方が簡単な場合があります。

databaseRegex and collectionsRegex each supports an options field, which you can use to configure regular expression options. Internally, mongosync passes the filter and options to the $regex operator. Options available to that operator can be used with Filtred Sync.

例、このフィルターは、accounts_ string で始まる salesデータベース内のコレクションと一致します。このフィルターでは、複数行の値を持つ string で各行の先頭または末尾の文字を照合するための オプション m と、ドット記号が改行文字 を含む すべての文字と一致するようにするオプション s も指定します。

"includeNamespaces": [
{
"database": "sales",
"collectionsRegex": {
"pattern": "^accounts_.+?$",
"options": "ms"
}
}
]
このページを評価