{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"MongoDB Import Integration","description":"MongoDB用Data Connectorは、MongoDBサーバーに保存されているドキュメント（レコード）をTreasure Dataにインポートできます。","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"mongodb-import-integration","__idx":0},"children":["MongoDB Import Integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MongoDB用Data Connectorは、MongoDBサーバーに保存されているドキュメント（レコード）をTreasure Dataにインポートできます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataの基本知識"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"接続の設定","__idx":2},"children":["接続の設定"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure コンソールからMongoDBデータコネクタのインスタンスを作成できます。MongoDBコネクタタイルで",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["作成"]},"を選択します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-223623.7ef9ab1bd405dc4a16ef8afd171bf080c78d6b5246be9666b94f183ff8c3a3d9.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"新しいmongodbコネクタの作成","__idx":3},"children":["新しいMongoDBコネクタの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MongoDBインスタンスに必要な認証情報を入力します。以下のパラメータを設定します。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Auth method"]},": 認証方法を指定します。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["\"Auto\"を選択した場合、コネクタは認証先のサーバーのバージョンに基づいて最適なメカニズムをネゴシエートします。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["サーバーのバージョンが3.0以上の場合、ドライバーはSCRAM-SHA-1メカニズムを使用して認証します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["それ以外の場合、ドライバーはMONGODB_CRメカニズムを使用して認証します。"]}]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Auth source"]},": ユーザーが定義されているデータベース名。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Username"]},": リモートデータベースに接続するためのユーザー名。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Password"]},": リモートデータベースに接続するためのパスワード。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use TLS?:"]}," TLS（SSL）を使用して接続する場合は、このボックスをチェックします。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Bypass certificate validations?:"]}," すべての証明書検証をバイパスする場合は、このボックスをチェックします。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use Service records?:"]}," MongoDB cloudでクラスタを作成する場合は有効にします。有効にすると、hostsの最初のホストのみが使用され、値はクラスタ名（例: ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://cluster0.be2g8go.mongodb.net"},"children":["cluster0.be2g8go.mongodb.net"]},"）である必要があります。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Hostname"]},": リモートサーバーのホスト名またはIPアドレス。（MongoDBのセットアップによっては、複数のIPアドレスを追加できます。）"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Port"]},": リモートサーバーのポート番号（デフォルトは27017）。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Options"]},": ドライバーに渡されるJDBCキーバリューペア（これらのオプションの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.mongodb.com/docs/drivers/java/sync/v4.3/fundamentals/connection/connection-options/"},"children":["Connection Options"]},"を参照してください）"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/screenshot-2024-12-23-at-15.02.47.9d4c0e70d91135ccba7d1dbe448d4ee2a516706d6a52e55daec42635f6e06c9c.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["必要な接続の詳細を入力した後、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Continue"]},"を選択します。後で接続の詳細を変更する必要がある場合に見つけられるように、接続に名前を付けます。この接続を組織内の他のユーザーと共有したい場合は、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Share with others"]},"を選択します。このボックスがチェックされていない場合、この接続はあなたにのみ表示されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create Connection"]},"を選択して接続を完了します。接続が成功すると、作成した接続が、指定した名前で接続リストに表示されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"treasure-dataへのデータ転送","__idx":4},"children":["Treasure Dataへのデータ転送"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["リモートデータベースへの接続を作成した後、データベースからTreasure Dataにデータをインポートできます。アドホックな1回限りの転送または定期的な間隔での繰り返し転送を設定できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224315.64f25506fcc9f2bc14966d409b8cabc45acbdf7836643901ab86b64d4faafc3d.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"データベースの詳細を入力fetch-from","__idx":5},"children":["データベースの詳細を入力（Fetch From）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["データを取り込むデータベースとテーブルの詳細を入力します。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Database name"]},": データを転送するデータベースの名前。（例: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["your_database_name"]},"）"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Collection Name:"]}," データを転送するコレクションの名前。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JSON Query:"]}," 返すレコードを指定します"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JSON Projection:"]}," 返すフィールドを指定します"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224340.405d69795491ebde55888a8fbe11660317b61b6b27f689c6e1d4028e9cf88b59.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次のステップでデータをプレビューするには、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Next"]},"を選択します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"プレビュー","__idx":6},"children":["プレビュー"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["接続にエラーがない場合は、インポートされるデータのプレビューが表示されます。プレビューを表示できない場合、またはプレビューの表示に問題がある場合は、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"mailto:support@treasuredata.com"},"children":["サポート"]},"にお問い合わせください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224456.10d710372f66ddf8eba2e55a4d879c02bc8aaf368f4312ea55491bbec9f51aac.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["プレビュー中およびデータインポートの実行時、レコードは1つの列にインポートされます。インポートに非標準のオプションを使用する必要がある場合は、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Advanced Settings"]},"を選択します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Advanced Settingsでは、特別な要件に対応するために転送の側面を変更できます。Preview > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Advanced Settings"]},"では、以下のフィールドが利用可能です。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Object ID field name"]},": インポートするObject IDフィールド名の名前。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Load only new records each run"]},": チェック/有効にすると、ソートするフィールドを指定する必要があります"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Sort by"]},": レコードのソートに使用するフィールド。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Load only new records each run"]},"がチェックされている場合は必須です。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Aggregation query"]}," : 集約のクエリ文字列。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.mongodb.com/manual/aggregation/"},"children":["Aggregation — MongoDB Manual"]},"と",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/"},"children":["Aggregation Pipeline Stages — MongoDB Manual"]},"も参照してください"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Output column name:"]}," レコードを出力する列の名前。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Stop on invalid record"]},": チェックすると、無効なレコードに遭遇した場合、転送は停止し、完了しません。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224507.a8b833e1d659a689964854dbb5930a92e67a48b186d8d72639dfd405d6aa227e.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"transfer-to","__idx":7},"children":["Transfer To"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このフェーズでは、データをインポートするTreasure Dataのターゲットデータベースとテーブルを選択します。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create new database"]},"または",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create new table"]},"を使用して、新しいデータベースまたはテーブルを作成できます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Database:"]}," データをインポートするデータベース。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Table"]},": データをインポートするデータベース内のテーブル。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Mode"]},": Append – 既存のテーブルにレコードを追加できます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Mode"]},": Replace – テーブル内の既存のデータを、インポートされるデータに置き換えます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Partition Key Seed"]},": パーティション化時間列として使用するlongまたはtimestamp列を選択します。時間列を指定しない場合、転送のアップロード時間が",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]},"列の追加と組み合わせて使用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Data Storage Timezone"]},": データが保存されるタイムゾーン。データもこのタイムゾーンで表示されます。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224524.1f7b4d78f5153602b37523ccb2e73e913df9dea0b1bbddf7c72a357bf64c289a.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"データ転送の頻度when","__idx":8},"children":["データ転送の頻度（When）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このフェーズでは、転送を1回だけ実行するか、指定した頻度で実行するようにスケジュールするかを選択できます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Once now"]},": 転送を1回だけ実行します。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Repeat…"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Schedule"]},": ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@hourly"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@daily"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@monthly"]},"、およびカスタム",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cron"]},"の3つのオプションを受け入れます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Delay Transfer"]},": 実行時間の遅延を追加します。"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Time Zone"]},": 'Asia/Tokyo'のような拡張タイムゾーン形式をサポートします。"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224537.28887603e0c4e2ea002679cd2bb054f427c237ea91a0bbd708e86992a40ff852.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["頻度を選択した後、",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Start Transfer"]},"を選択して転送を開始します。エラーがなければ、Treasure Dataへの転送が完了し、データが利用可能になります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"my-input-transfers","__idx":9},"children":["My Input Transfers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["完了したばかりの転送や他のデータコネクタジョブを確認する必要がある場合は、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["My Input Transfers"]},"セクションで転送のリストを表示できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image-20191004-224554.3b670d4e1d06bcc989dfa5d4800a075c82728ec644d8e8b176aa4fec90c89480.a49c45cd.png","alt":""},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"cliを使用したコネクタの設定","__idx":10},"children":["CLIを使用したコネクタの設定"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["コマンドラインインターフェイスからMongoDBデータコネクタを使用することもできます。以下の手順は、CLIを使用してデータをインポートする方法を示しています。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"tdコマンドv0119以降をインストール","__idx":11},"children":["'td'コマンドv0.11.9以降をインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最新の",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://toolbelt.treasuredata.com/"},"children":["TD Toolbelt"]},"をインストールします。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td --version\n0.11.10\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"シード設定ファイルの作成seedyml","__idx":12},"children":["シード設定ファイルの作成（seed.yml）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["まず、MongoDBの詳細を含む",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["seed.yml"]},"を準備します。以下の内容で",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["seed.yml"]},"を作成します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mongodb\n  hosts:\n    - {host: HOST, port: PORT}\n  auth_method: auto\n  #auth_source: AUTH_SOURCE_DB\n  user: USER\n  password: PASSWORD\n  database: DATABASE\n  collection: COLLECTION\n  options:\n    connectTimeoutMS: 10000\n    socketTimeoutMS: 10000\n    projection: '{\"_id\": 0}'\n    query: '{}'\n    sort: '{}'\n    stop_on_invalid_record: true\nout:\n  mode: append\nexec: {}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MongoDB用Data Connectorは、指定されたコレクションに保存されているすべてのドキュメントをインポートします。以下のオプションを使用して、フィールドをフィルタリング、クエリを指定、またはソートできます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"321-projectionオプション","__idx":13},"children":["3.2.1. Projectionオプション"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["クエリ結果の",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.mongodb.com/manual/reference/operator/projection/positional/"},"children":["projection"]},"に使用されるJSONドキュメント。ドキュメント内のフィールドは、この条件に一致する場合にのみ使用されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"projection: '{ \"_id\": 1, \"user_id\": 1, \"company\": 1 }'\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"queryオプション","__idx":14},"children":["Queryオプション"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ソースコレクションの",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.mongodb.com/manual/tutorial/query-documents/"},"children":["querying"]},"に使用されるJSONドキュメント。この条件に一致する場合、ドキュメントはコレクションから読み込まれます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"query: '{ user_id: { $gte: 20000 } }'\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sortオプション","__idx":15},"children":["Sortオプション"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["結果の順序"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"sort: '{ \"field1\": 1, \"field2\": -1}' # field1 昇順、field2 降順\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このオプションはaggregationオプションと一緒に使用できません。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["利用可能な",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["out"]},"モードの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/mongodb-import-integration#h1__1835053169"},"children":["付録"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"aggregationオプション","__idx":16},"children":["Aggregationオプション"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["集約クエリ"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"aggregation: '{ $match: { field1: { $gt: 1}} }' # field1が1より大きい場合\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このオプションはsortオプションと一緒に使用できません。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["利用可能な",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["out"]},"モードの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/ja/int/mongodb-import-integration#h1__1835053169"},"children":["付録"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"フィールドの推測loadymlの生成","__idx":17},"children":["フィールドの推測（load.ymlの生成）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Data Connector MongoDBは、MongoDBのドキュメントを単一の列として読み込むため、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["connector:guess"]},"をサポートしていません。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["load.yml"]},"のすべての設定を編集してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["preview"]},"コマンドを使用して、システムがドキュメントをどのように解析するかをプレビューできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:preview load.yml\n+---------------------------------------------------------------------------------------------------------------------+\n| record:json                                                                                                         |\n+---------------------------------------------------------------------------------------------------------------------+\n| \"{\\\"user_id\\\":11200,\\\"company\\\":\\\"AA Inc.\\\",\\\"customer\\\":\\\"David\\\",\\\"created_at\\\":\\\"2015-03-31T06:12:37.000Z\\\"}\"    |\n| \"{\\\"user_id\\\":20313,\\\"company\\\":\\\"BB Imc.\\\",\\\"customer\\\":\\\"Tom\\\",\\\"created_at\\\":\\\"2015-04-01T01:00:07.000Z\\\"}\"      |\n| \"{\\\"user_id\\\":32132,\\\"company\\\":\\\"CC Inc.\\\",\\\"customer\\\":\\\"Fernando\\\",\\\"created_at\\\":\\\"2015-04-01T10:33:41.000Z\\\"}\" |\n| \"{\\\"user_id\\\":40133,\\\"company\\\":\\\"DD Inc.\\\",\\\"customer\\\":\\\"Cesar\\\",\\\"created_at\\\":\\\"2015-04-02T05:12:32.000Z\\\"}\"    |\n| \"{\\\"user_id\\\":93133,\\\"company\\\":\\\"EE Inc.\\\",\\\"customer\\\":\\\"Jake\\\",\\\"created_at\\\":\\\"2015-04-02T14:11:13.000Z\\\"}\"     |\n+---------------------------------------------------------------------------------------------------------------------+\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["データコネクタは、\"boolean\"、\"long\"、\"double\"、\"string\"、\"timestamp\"タイプの解析をサポートしています。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["また、データロードジョブを実行する前に、ローカルデータベースとテーブルを作成する必要があります。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td database:create td_sample_db\n$ td table:create td_sample_db td_sample_table\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ロードジョブの実行","__idx":18},"children":["ロードジョブの実行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最後に、ロードジョブを送信します。データのサイズによっては、数時間かかる場合があります。データを保存するTreasure Dataのデータベースとテーブルを指定します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataのストレージは時間でパーティション化されているため、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--time-column"]},"オプションを指定してください（",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/data-partitioning-in-treasure-data"},"children":["Data Partitioning in Treasure Data"]},"を参照）。オプションが指定されていない場合、Data Connectorは最初の",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["long"]},"または",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["timestamp"]},"列をパーティション化時間として選択します。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--time-column"]},"で指定する列のタイプは、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["long"]},"または",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["timestamp"]},"タイプである必要があります。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["データに時間列がない場合は、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["add_time"]},"フィルタオプションを使用して追加できます。詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/add_time-filter-function"},"children":["add_time filter plugin"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["JSON列を展開したい場合は、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expand_json"]},"フィルタオプションを使用して追加できます。詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/expand_json-filter-function"},"children":["expand_json filter plugin"]},"を参照してください"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:issue load.yml --database td_sample_db --table td_sample_table --time-column created_at\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["connector:issueコマンドは、データベース*(td_sample_db)",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["とテーブル"]},"(td_sample_table)",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["がすでに作成されていることを前提としています。データベースまたはテーブルがTDに存在しない場合、connector:issueコマンドは失敗するため、データベースとテーブルを",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/data-management"},"children":["手動で"]},"作成するか、",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["td connector:issue"]},"コマンドで"]},"--auto-create-table*オプションを使用してデータベースとテーブルを自動作成してください:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:issue load.yml --database td_sample_db --table td_sample_table --time-column created_at --auto-create-table\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Data Connectorはサーバー側でレコードをソートしません。時間ベースのパーティション化を効果的に使用するには、事前にレコードをソートしてください。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]},"というフィールドがある場合は、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--time-column"]},"オプションを指定する必要はありません。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"td connector:issue load.yml --database td_sample_db --table td_sample_table\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"インクリメンタルロード","__idx":19},"children":["インクリメンタルロード"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["incremental_field"]},"および",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["last_record"]},"オプションを利用して、日付情報を含むテーブル内のフィールドを指定することで、レコードをインクリメンタルにロードできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mongodb\n  hosts:\n    - {host: HOST, port: PORT}\n  user: USER\n  password: PASSWORD\n  database: DATABASE\n  collection: COLLECTION\n  projection: '{\"_id\": 0}'\n  incremental_field:\n    - \"field1\"\n  last_record: {\"field1\": {\"$date\": \"2015-01-25T13:23:15.000Z\"}}\n  stop_on_invalid_record: true\nout:\n  mode: append\n  exec: {}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["コネクタは自動的にクエリとソート値を作成します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"query '{ field1: { $gt: {\"$date\": \"2015-01-25T13:23:15.000Z\"} }}' # field1 > \"2015-01-25T13:23:15.000Z\"\nsort '{\"field1\", 1}' # field1 昇順\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"複数フィールドでのインクリメンタルロード","__idx":20},"children":["複数フィールドでのインクリメンタルロード"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["incremental_fields"]},"に複数のフィールドを指定することもできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"incremental_field:\n  - \"field1\"\n  - \"field2\"\nlast_record: {\"field1\": {\"$date\": \"2015-01-25T13:23:15.000Z\"}, \"field2\": 13215}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["コネクタは'AND'条件を使用してクエリとソート値を作成します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"query '{ field1: { $gt: {\"$date\": \"2015-01-25T13:23:15.000Z\"} }, field2: { $gt: 13215}}' # field1 > \"2015-01-25T13:23:15.000Z\" AND field2 > 13215\nsort '{\"field1\", 1, \"field2\", 1}' # field1 昇順、field2 昇順\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["incremental\\_field"]},"を指定する場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sort"]},"オプションは使用できません。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["incremental\\_field"]},"を指定する場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aggregation"]},"オプションは使用できません。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["フィールドタイプがObjectIdまたはDateTimeの場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["last\\_record"]},"を特殊文字で指定する必要があります。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ObjectIdフィールド"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mongodb\n  incremental_field:\n    - \"_id\"\n  last_record: {\"_id\": {\"$oid\": \"5739b2261c21e58edfe39716\"}}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["DateTimeフィールド"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mongodb\n  incremental_field:\n    - \"time_field\"\n  last_record: {\"time_field\": {\"$date\": \"2015-01-25T13:23:15.000Z\"}}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"スケジュールされた実行","__idx":21},"children":["スケジュールされた実行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MongoDBデータインポートの定期的なデータコネクタ実行をスケジュールできます。高可用性を確保するために、スケジューラーを慎重に設定しています。この機能を使用することで、ローカルデータセンターに",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cron"]},"デーモンを用意する必要がなくなります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"スケジュールの作成","__idx":22},"children":["スケジュールの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td connector:create"]},"コマンドを使用して新しいスケジュールを作成できます。スケジュールの名前、cronスタイルのスケジュール、データが保存されるデータベースとテーブル、およびData Connector設定ファイルが必要です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:create \\\n    daily_import \\\n    \"10 0 * * *\" \\\n    td_sample_db \\\n    td_sample_table \\\n    load.yml\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataのストレージは時間でパーティション化されているため、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--time-column"]},"オプションを指定することもお勧めします（",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/data-partitioning-in-treasure-data"},"children":["data partitioning"]},"を参照）。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:create \\\n    daily_import \\\n    \"10 0 * * *\" \\\n    td_sample_db \\\n    td_sample_table \\\n    load.yml \\\n    --time-column created_at\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cron"]},"パラメータは、3つの特別なオプション（",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@hourly"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@daily"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@monthly"]},"）も受け入れます。"," ","デフォルトでは、スケジュールはUTCタイムゾーンで設定されます。-tまたは--timezoneオプションを使用して、タイムゾーンでスケジュールを設定できます。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--timezone"]},"オプションは、'Asia/Tokyo'、'America/Los_Angeles'などの拡張タイムゾーン形式のみをサポートしています。PST、CSTなどのタイムゾーンの略語は",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["サポートされておらず"]},"、予期しないスケジュールになる可能性があります。"]}]},"headings":[{"value":"MongoDB Import Integration","id":"mongodb-import-integration","depth":1},{"value":"前提条件","id":"前提条件","depth":2},{"value":"接続の設定","id":"接続の設定","depth":2},{"value":"新しいMongoDBコネクタの作成","id":"新しいmongodbコネクタの作成","depth":2},{"value":"Treasure Dataへのデータ転送","id":"treasure-dataへのデータ転送","depth":2},{"value":"データベースの詳細を入力（Fetch From）","id":"データベースの詳細を入力fetch-from","depth":3},{"value":"プレビュー","id":"プレビュー","depth":3},{"value":"Transfer To","id":"transfer-to","depth":3},{"value":"データ転送の頻度（When）","id":"データ転送の頻度when","depth":3},{"value":"My Input Transfers","id":"my-input-transfers","depth":3},{"value":"CLIを使用したコネクタの設定","id":"cliを使用したコネクタの設定","depth":2},{"value":"'td'コマンドv0.11.9以降をインストール","id":"tdコマンドv0119以降をインストール","depth":3},{"value":"シード設定ファイルの作成（seed.yml）","id":"シード設定ファイルの作成seedyml","depth":3},{"value":"3.2.1. Projectionオプション","id":"321-projectionオプション","depth":3},{"value":"Queryオプション","id":"queryオプション","depth":3},{"value":"Sortオプション","id":"sortオプション","depth":3},{"value":"Aggregationオプション","id":"aggregationオプション","depth":3},{"value":"フィールドの推測（load.ymlの生成）","id":"フィールドの推測loadymlの生成","depth":2},{"value":"ロードジョブの実行","id":"ロードジョブの実行","depth":2},{"value":"インクリメンタルロード","id":"インクリメンタルロード","depth":2},{"value":"複数フィールドでのインクリメンタルロード","id":"複数フィールドでのインクリメンタルロード","depth":3},{"value":"スケジュールされた実行","id":"スケジュールされた実行","depth":2},{"value":"スケジュールの作成","id":"スケジュールの作成","depth":3}],"frontmatter":{"seo":{"title":"MongoDB Import Integration","description":"MongoDB用Data Connectorは、MongoDBサーバーに保存されているドキュメント（レコード）をTreasure Dataにインポートできます。"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/mongodb-import-integration","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}