AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

스트리밍 쓰기 구성 옵션

스트리밍 모드에서 MongoDB에 데이터를 쓸 때 다음 속성을 구성할 수 있습니다.

참고

SparkConf을(를) 사용하여 커넥터의 쓰기 구성을 설정하는 경우 각 속성 앞에 spark.mongodb.write.을(를) 접두사로 붙입니다.

속성 이름
설명

connection.uri

필수 사항입니다.
연결 문자열 구성 키입니다.

기본값: mongodb://localhost:27017/

database

필수 사항입니다.
데이터베이스 이름 구성입니다.

collection

필수 사항입니다.
컬렉션 이름 구성입니다.

comment

The comment to append to the write operation. Comments appear in the output of the Database Profiler.

Default: None

mongoClientFactory

MongoClientFactory 구성 키입니다.
com.mongodb.spark.sql.connector.connection.MongoClientFactory 인터페이스를 구현해야 하는 사용자 지정 구현을 지정할 수 있습니다.

기본값: com.mongodb.spark.sql.connector.connection.DefaultMongoClientFactory

convertJson

connector가 string 값을 파싱하고 확장된 JSON을 BSON으로 변환할지 여부를 지정합니다.

이 설정은 다음 값을 허용합니다.

  • any: connector는 모든 JSON 값을 BSON으로 변환합니다.

    • "{a: 1}" 이 {a: 1}이 됩니다.

    • "[1, 2, 3]" 이 [1, 2, 3]이 됩니다.

    • "true" 이 true이 됩니다.

    • "01234" 이 1234이 됩니다.

    • "{a:b:c}" 은(는) 변하지 않습니다.

  • objectOrArrayOnly: connector는 JSON 객체와 배열만 BSON으로 변환합니다.

    • "{a: 1}" 이 {a: 1}이 됩니다.

    • "[1, 2, 3]" 이 [1, 2, 3]이 됩니다.

    • "true" 은(는) 변하지 않습니다.

    • "01234" 은(는) 변하지 않습니다.

    • "{a:b:c}" 은(는) 변하지 않습니다.

  • false: connector는 모든 값을 문자열로 남깁니다.

기본값입니다: false

idFieldList

컬렉션 데이터를 분할할 필드 또는 필드 목록을 지정합니다. 둘 이상의 필드를 지정하려면 다음 예시와 같이 심표를 사용하여 필드를 구분합니다.

"fieldName1,fieldName2"

기본값입니다: _id

ignoreNullValues

true인 경우 connector는 쓰기 시 배열 및 중척 문서의 null 값을 포함하여 null 값을 모두 무시합니다.

기본값: false

maxBatchSize

대량 작업에서 일괄 처리할 최대 작업 수를 지정합니다.

기본값: 512

operationType

쓰기 작업의 유형을 지정합니다. 다음 값 중 하나로 설정할 수 있습니다.

  • insert: 데이터를 삽입합니다.

  • replace: idFieldList 값과 일치하는 기존 문서를 새 데이터로 바꿉니다. 일치하는 항목이 없으면 upsertDocument 값은 connector가 새 문서를 삽입하는지 여부를 나타냅니다.

  • update: idFieldList 값과 일치하는 기존 문서를 새 데이터로 업데이트합니다. 일치하는 항목이 없으면 upsertDocument 값은 connector가 새 문서를 삽입하는지 여부를 나타냅니다.


기본값입니다: replace

ordered

순서가 지정된 대량 작업을 수행할지 여부를 지정합니다.

기본값: true

upsertDocument

true일 때 일치하는 항목이 없는 경우 교체 및 업데이트 작업을 수행하면 데이터가 삽입됩니다.

time series 컬렉션의 경우 upsertDocument false로 설정해야 합니다.

기본값: true

writeConcern.w

Specifies w, a write-concern option requesting acknowledgment that the write operation has propagated to a specified number of MongoDB nodes.

For a list of allowed values for this option, see WriteConcern w Option in the MongoDB Server manual.

Default: Acknowledged

writeConcern.journal

Specifies j, a write-concern option requesting acknowledgment that the data has been written to the on-disk journal for the criteria specified in the w option. You can specify either true or false.

For more information on j values, see WriteConcern j Option in the MongoDB Server manual.

writeConcern.wTimeoutMS

Specifies wTimeoutMS, a write-concern option to return an error when a write operation exceeds the specified number of milliseconds. If you use this optional setting, you must specify a nonnegative integer.

For more information on wTimeoutMS values, see WriteConcern wtimeout in the MongoDB Server manual.

checkpointLocation

커넥터가 체크포인트 정보를 쓰는 디렉토리의 절대 파일 경로입니다.

체크포인트에 대한 자세한 내용은 Spark Structured Streaming Programming Guide를 참조하세요.

기본값: 없음

forceDeleteTempCheckpointLocation

기존 체크포인트 데이터를 삭제할지 여부를 지정하는 불리언 값입니다.

기본값: false

truncateMode

오버라이트를 수행할 때 컬렉션을 잘라내는 방법을 지정합니다. 이 옵션을 다음 값 중 하나로 설정할 수 있습니다.

  • TruncateMode.DROP: 기본값입니다. 컬렉션 제거합니다.

  • TruncateMode.TRUNCATE: 컬렉션 의 모든 항목을 삭제하지만 인덱스, 컬렉션 옵션 및 모든 샤딩 구성은 보존합니다. 이는 드롭 작업보다 느립니다.

ignoreDuplicatesOnInsert

true으로 설정되면 커넥터는 정렬되지 않은 삽입 작업을 수행할 때 중복 키 오류를 무시합니다. 삽입되는 데이터에는 _id 필드 값 또는 idFieldList 옵션에 지정된 필드가 포함되어야 합니다.

기본값: false

SparkConf를 사용하여 이전 설정을 지정하는 경우 해당 설정을 connection.uri 설정에 포함하거나 개별적으로 나열할 수 있습니다.

다음 코드 예시에서는 데이터베이스, 컬렉션, convertJson 설정을 connection.uri 설정의 일부로 지정하는 방법을 보여줍니다.

spark.mongodb.write.connection.uri=mongodb://127.0.0.1/myDB.myCollection?convertJson=any

connection.uri를 더 짧게 유지하고 설정을 더 읽기 쉽게 만들려면 대신 개별적으로 지정할 수 있습니다.

spark.mongodb.write.connection.uri=mongodb://127.0.0.1/
spark.mongodb.write.database=myDB
spark.mongodb.write.collection=myCollection
spark.mongodb.write.convertJson=any

중요

connection.uri 및 해당 줄 모두에 설정을 지정하면 connection.uri 설정이 우선 적용됩니다. 예를 들어 다음 구성에서 연결 데이터베이스는 foobar입니다.

spark.mongodb.write.connection.uri=mongodb://127.0.0.1/foobar
spark.mongodb.write.database=bar
이 페이지 평가하기