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

MongoDB Search 인덱스의 필드 매핑 정의

MongoDB 검색 인덱스 생성할 때 다음 메서드를 사용하여 인덱스 할 필드를 지정할 수 있습니다.

  • 동적 매핑: MongoDB 검색을 활성화하여 기본값 또는 구성된 필드 유형 세트(typeSet)에 따라 모든 필드를 자동으로 인덱싱합니다.

  • 정적 매핑: 인덱스 할 필드를 지정할 수 있습니다.

  • 기본적으로 MongoDB Search는 복제본 세트 또는 단일 샤드에서 인덱스 객체 수가 2,100,000,000 개를 초과하는 인덱스에 대한 변경 사항 복제를 중단합니다. 여기서 각 인덱스된 문서 또는 중청된 embeddedDocument는 하나의 객체로 간주됩니다. 이는 인덱스를 쿼리할 수 있지만 오래된 결과가 나올 수 있음을 의미합니다.

    If you plan to index fields that might exceed 2,100,000,000 objects, where an index object is a top-level document or an embedded document, use the numPartitions index option to partition your index (supported only on Search Nodes deployment) or shard your cluster.

  • 필드 이름 시작 부분에 달러($) 기호가 포함된 필드는 인덱싱할 수 없습니다.

  • 자동 완성 필드 유형은 큰 인덱스를 생성할 수 있으며, 다른 필드 유형보다 빌드하는 데 시간이 더 오래 걸릴 수 있습니다. 사용자 지정 typeSet 정의에 autocomplete 형을 포함하여 동적 매핑에서 사용할 수 있지만, 의도하지 않은 성능, 저장 및 스코링 영향을 피하기 위해 정적 매핑에서만 autocomplete 형을 사용하는 것을 권장합니다. 자세히 알아보려면 자동 완성을 위한 필드 인덱싱 방법 및 MongoDB Search 인덱스 성능 향상을 참조하세요.

The following syntax demonstrates how to enable MongoDB Search to index fields using dynamic and static mappings. To learn more about dynamic and static mappings, see Dynamic and Static Mappings.

1{
2 "mappings": {
3 "dynamic": true|false | {
4 "typeSet": "<typeset-name>"
5 },
6 "fields": {
7 "<field-name>": {
8 "type": "<field-type>",
9 ...
10 },
11 ...
12 }
13 },
14 "typeSets": [
15 {
16 "name": "<typeset-name>",
17 "types": [
18 {
19 "type": "<field-type>",
20 ...
21 },
22 ...
23 ]
24 },
25 ...
26 ]
27}

다음을 사용하여 MongoDB 검색하다를 구성할 수 있습니다.

  • 기본값 또는 구성된 유형 설정하다 (typeSet)을 기반으로 필드를 자동으로 인덱스 하는 동적 매핑

  • 지정된 필드만 인덱스 하는 정적 매핑

You can also use dynamic mappings with static mappings. Static mappings override the dynamic mappings configuration. When you define a static mapping for a field, MongoDB Search indexes that field only according to the static mapping definition. The dynamic mapping no longer applies to that field.

예를 들어 dynamic: true을(를) 활성화하면 MongoDB Search는 기본적으로 string 필드를 string 유형으로 인덱스합니다. 그 다음 특정 string 필드에 대한 정적 autocomplete 매핑을 추가하면 MongoDB Search는 해당 필드를 autocomplete 유형으로만 인덱스합니다. 정적 매핑에 string를 명시적으로 포함하지 않는 한 string 로도 인덱스되지 않습니다. 필드를 두 유형 모두 인덱스하려면 필드의 정적 매핑 배열에 두 유형을 모두 정의해야 합니다.

MongoDB Search 동적 매핑을 사용하면 데이터의 필드를 자동으로 재귀적으로 인덱스 하도록 MongoDB Search를 구성할 수 있습니다. 필드는 기본값 유형을 설정하여 기반으로 하거나 typeSet를 구성하여 인덱싱할 수 있습니다.

동적 매핑을 활성화 하거나 구성할 수 있습니다.

  • 루트 mappings 수준에서 전체 문서 에 적용 .

  • [권장] document 내에서 지정된 객체 에 적용 필드 유형입니다.

  • [권장] embeddedDocuments 필드 내에서 요소별 쿼리 비교가 필요한 지정된 객체 배열에 적용 필드 유형($elemMatch과 유사)입니다.

참고

모범 사례

동적 매핑은 고유한 필드를 많이 인덱싱할 수 있으며, 이로 인해 더 많은 디스크 공간을 차지하고 성능이 떨어질 수 있습니다. 정기적으로 변경되거나 알 수 없는 필드를 인덱싱해야 하는 경우에만 동적 매핑을 사용하세요. 항상 문서 내에서 동적 매핑을 사용하고 부모 문서 수준에서는 사용하지 마세요.

동적 매핑을 사용하여 데이터를 인덱스 하는 경우:

  • 또한 MongoDB Search는 데이터의 document 객체 에서 typeSet 가 지원하는 모든 중첩 필드를 동적으로 인덱싱합니다.

  • 필드 에 다형성 데이터가 포함된 경우, MongoDB Search는 인덱스 에 사용된 typeSet 에서 지원하는 모든 유형으로 필드 를 자동으로 인덱싱합니다. 필드 typeSet에서 지원하지 않는 유형의 데이터가 포함되어 있는 경우, MongoDB Search는 해당 데이터를 인덱스 하지 않습니다.

MongoDB Search uses the default typeSet when dynamic is set to true. In the default typeSet, MongoDB Search indexes the BSON types as MongoDB Search field types. The following table shows the BSON types that MongoDB Search automatically indexes as MongoDB Search field types when you use the default typeSet. MongoDB Search also automatically indexes the following BSON types when they are contained within arrays and objects.

BSON 유형
MongoDB 검색 필드 유형

부울

날짜

Double, 32-비트 정수, 64-비트 정수

ObjectId

문자열

UUID

Null

다음은 동적 매핑에 대한 기본값 유형 집합을 활성화하는 구문입니다.

1{
2 "mappings": {
3 "dynamic": true
4 }
5}

For index examples that demonstrate indexing all fields using the default typeSet, see Dynamic Mapping Examples.

Specify the MongoDB Search field types to index dynamically by configuring a typeSet. You can configure any BSON type to be automatically indexed as any MongoDB Search field type except document, embeddedDocuments, vector, or deprecated field types.

typeSet 의 구문은 다음과 같습니다.

참고

Atlas UI Visual Editor에서는 typeSet을(를) 구성할 수 없습니다. Atlas UI JSON Editor를 대신 사용하세요.

1{
2 "mappings": {
3 "dynamic": {
4 "typeSet": "<typeset-name>"
5 },
6 "fields": {
7 "<field-name>": {
8 "type": "<field-type>",
9 ...
10 },
11 ...
12 }
13 },
14 "typeSets": [
15 {
16 "name": "<typeset-name>",
17 "types": [
18 {
19 "type": "<field-type>"
20 },
21 ...
22 ]
23 },
24 ...
25 ]
26}

typeSet를 구성하기 전에 다음 사항을 고려하세요.

  • 동일한 typeSet 객체 에서 동일한 필드 유형을 여러 번 정의할 수 없습니다. 각 필드 유형에 대해 하나의 typeSet 정의만 구성할 수 있습니다.

    예시 들어 동일한 typeSet 정의에서 number 유형에 대해 여러 구성을 정의할 수 없습니다.

  • multi 분석기 사용하여 동적 매핑을 구성할 수 있습니다.

사용자 지정 typeSet 구성을 사용하는 방법을 보여주는 인덱스 예시는 동적 매핑 예시.를 참조하세요.

정적 매핑을 사용하여 동적으로 인덱싱하지 않으려는 필드에 대한 인덱스 옵션을 구성하거나 인덱스 의 다른 필드와 독립적으로 단일 필드 구성합니다. 정적 매핑을 사용하는 경우 MongoDB 검색 인덱스는 mappings.fields에 지정한 필드만 인덱싱합니다. 정적 매핑을 사용하여 필드가 인덱스에 포함되지 않도록 제외할 수도 있습니다.

To use static mappings to configure index options for only some fields, set mappings.dynamic to false and specify the field name, data type, and other configuration options for each field that you want to index. You can specify the fields in any order.

mappings.dynamic 필드를 생략하는 경우 기본값인 false로 설정됩니다.

1{
2 "mappings": {
3 "dynamic": true|false,
4 "fields": {
5 "<field-name>": {
6 "type": "<field-type>",
7 ...
8 },
9 ...
10 }
11 }
12}

중첩된 필드 에 대한 인덱스 정의하려면 해당 중첩 필드 의 각 상위 필드 에 대한 매핑을 정의해야 합니다. 점 표기법 사용하여 중첩된 필드를 정적으로 인덱스 할 수 없습니다. 예제는 아래의 예제 또는 결합된 매핑 예제 를 참조하세요.

You can use static mappings to index fields as multiple types. To index a field as multiple types, define the types in the field definition array for the field. You can index any field as any supported types using static mappings. To learn more, see MongoDB Search Field Types.

다음 예에서는 필드를 여러 유형으로 인덱싱하기 위한 필드 정의를 보여줍니다.

1{
2 "mappings": {
3 "dynamic": true|false | {
4 "typeSet": "<type-set-name>"
5 },
6 "fields": {
7 "<field-name>": [
8 {
9 "type": "<field-type>",
10 ...
11 },
12 {
13 "type": "<field-type>",
14 ...
15 },
16 ...
17 ],
18 ...
19 }
20 }.
21 "typeSets": [
22 {
23 "name": "<typeset-name>",
24 "types": [
25 {
26 "type": "<field-type>"
27 },
28 ...
29 ]
30 },
31 ...
32 ]
33}

For other index examples that demonstrate static mappings, see Static Mapping Example.

MongoDB Search doesn't support the following BSON data types:

  • Decimal128

  • 범위가 있는 자바스크립트 코드

  • 최대 키

  • Min key

  • 정규 표현식

  • 타임스탬프

MongoDB Search automatically stores fields of type string on mongot. You can store fields of all supported data types on MongoDB Search using the Define Stored Source Fields in Your MongoDB Search Index option in your index definition. To learn more about mongot and MongoDB Search node architecture, see MongoDB Search Deployment Options.

The following table enumerates the supported BSON data types and the MongoDB Search field types that you can use to index the BSON data types. The table also lists the operators and collectors that you can use to query the field values.

이러한 연산자는 문자열 배열 지원 하지 않습니다.

MongoDB Search는 정적 및 동적으로 인덱싱된 MongoDB 모두에 대해 null 값을 자동으로 인덱싱하기 때문에 null 값을 인덱싱 위한 필드 유형을 포함하지 않습니다.

더 이상 사용되지 않습니다. 더 이상 사용되지 않는 패싯 필드 유형과 업데이트된 해당 필드 유형에 대해 자세히 학습 보려면 패싯의 필드 유형 비교를 참조하세요.

double 또는 int 값의 배열입니다.

참고

You can store fields of all supported data types on MongoDB Search using the storedSource option.

The following sample index definitions on the sample_mflix.movies collection demonstrate how to index fields using dynamic and static mappings. You can load the sample data on your cluster to try the examples. To learn more about how to create MongoDB Search indexes, see MongoDB Search Quick Start.

다음 샘플 인덱스 정의는 동적 매핑을 사용하는 방법을 보여줍니다.

다음 샘플 인덱스 정의는 정적 매핑을 사용하는 방법을 보여줍니다.

다음 인덱스 정의 예시에서는 동적 매핑과 정적 매핑을 결합합니다.