Docs Menu
Docs Home
/
Atlas
/ /

Atlas Search 인덱스 관리

이 페이지의 내용

  • 고려 사항
  • 필요한 액세스 권한
  • Atlas Search 인덱스 만들기
  • Atlas Search 인덱스 보기
  • Atlas Search 인덱스 초안 재개 또는 삭제
  • Atlas Search 인덱스 편집
  • 기존 인덱스 업데이트
  • Atlas Search 인덱스 삭제
  • 인덱스 크기 추정
  • 인덱스 상태 검토
  • 자세히 알아보기
  • 학습 계속하기

Atlas Search 인덱스 데이터를 쉽게 검색할 수 있는 형식으로 분류하는 데이터 구조입니다. 용어와 해당 용어가 포함된 문서 간의 매핑입니다. Atlas Search 인덱스를 사용하면 특정 식별자를 사용하여 문서를 더 빠르게 검색 활성화 . Atlas Search 사용하여 Atlas cluster 의 데이터를 쿼리 하려면 Atlas Search Search 인덱스 구성해야 합니다.

단일 필드 또는 여러 필드에 대해 Atlas Search 인덱스를 만들 수 있습니다. 쿼리 시점에 관련 데이터를 포함하는 문서를 빠르게 검색할 수 있도록, 데이터를 정렬하거나 필터링하는 데 정기적으로 사용하는 필드를 인덱싱하는 것이 좋습니다.

Atlas Search 인덱스를 정의한 컬렉션 을 변경하는 경우 최신 데이터를 쿼리에 즉시 사용하지 못할 수 있습니다. 그러나 mongot 는 변경 스트림을 모니터링하여 저장된 데이터 사본을 업데이트 할 수 있으며, Atlas Search 인덱스는 최종적으로 일관적인 유지합니다.

인덱스 정의를 변경하면mongot 는 배경 에서 새 인덱스 자동으로 다시 작성하는 동시에 이전 인덱스 로 쿼리를 계속 제공 다운타임이 없는지 mongot mongod 확인합니다. 이는 동일한 노드 에 및 프로세스를 배포 때와 다른 노드에 프로세스를 배포 때 발생합니다. Atlas 미사용 데이터 암호화를 활성화 하거나 비활성화할 때도 인덱스를 다시 작성합니다.

검색 배포의 토폴로지를 변경하는 경우 Atlas Search는 이전 노드를 제거하기 전에 모든 새 노드에 인덱스를 프로비저닝하고 빌드하여 쿼리 중단 시간이 발생하지 않도록 합니다.

mongod 프로세스와 mongot 프로세스가 모두 동일한 노드에서 실행 배포서버의 경우, Atlas Search 인덱스를 다시 작성해야 하는 변경 사항(예: 인덱스 업데이트 필요한 일부 Atlas Search 기능)이 포함된 경우, Atlas 추가 이전 노드는 계속해서 쿼리를 제공 동안 인덱스 빌드 할 수 있습니다.

경고

이미 Atlas Search 인덱스가 있는 컬렉션을 샤드하는 경우, 컬렉션이 샤드에 표시되기 시작할 때 잠시 동안 쿼리 중단 시간이 발생할 수 있습니다. 또한 이미 샤드된 컬렉션에 대한 샤드를 추가하고 Atlas Search 인덱스가 포함된 경우, 추가된 샤드에서 초기 동기화 프로세스가 완료될 때까지 해당 컬렉션에 대한 검색 쿼리가 실패합니다. 자세한 내용은 초기 동기화 프로세스를 참조하세요.

중요

$out 집계 단계를 사용하여 기존 Atlas Search 인덱스 있는 컬렉션 을 수정하는 경우 검색 인덱스 삭제 하고 다시 만들어야 합니다. 가능하면 대신 $merge를 사용하는 것이 $out 좋습니다.

전용 검색 노드를 배포하여 성능, 확장성 및 리소스 격리를 개선할 수 있습니다. 검색 노드를 배포한 경우 다음 사항을 고려합니다.

  • 샤드를 추가하고 조정하면 Atlas Search 인덱스를 다시 빌드하도록 트리거됩니다. 이렇게 인덱스를 다시 빌드하는 중에 인덱스에 최근 데이터가 없을 수도 있습니다. 따라서 해당 샤드의 데이터에 대한 쿼리가 실패하거나 잘못된 결과를 반환할 수 있습니다.

  • Atlas Search 인덱스가 있는 컬렉션 리샤딩하는 경우 리샤딩 작업이 완료되면 컬렉션 의 Atlas Search 인덱스를 사용할 수 없게 됩니다. 작업이 완료되면 Atlas Search 인덱스를 삭제 하고 생성해야 합니다.

  • 데이터베이스의 기본 샤드를 변경하는 명령을 실행할 경우, 작업이 완료되면 이 데이터베이스 아래에 있는 샤딩되지 않은 컬렉션에 대한 Atlas 검색 인덱스를 사용할 수 없게 됩니다. 작업이 완료되면movePrimary Atlas 검색 인덱스를 삭제하고 새 인덱스를 만들어야 합니다 .

Atlas Search 노드 아키텍처에 대해 자세히 학습 Atlas Search 배포 옵션을 참조하세요.

프로젝트 사용자 역할 또는 데이터베이스 사용자 역할을 할당하여 이 가이드 에 설명된 Atlas Search 인덱스 작업을 수행하는 데 필요한 사용자 권한에 대한 액세스 제공할 수 있습니다.

다음 표는 지정된 Atlas Search 작업에 대해 다음 프로젝트 역할이 지원 액세스 모드를 보여줍니다.

역할
Atlas Search 작업
Atlas UI
Atlas CLI
Atlas API [1]

Atlas Search 인덱스 및 분석기를 봅니다.

Atlas Search 인덱스 및 분석기를 만들고, 보고, 업데이트, 삭제 .

Atlas 검색 인덱스를 생성, 확인, 업데이트 및 삭제합니다.

[1] 각 역할은 Atlas Administration API에서 Atlas Search API 엔드포인트 의 하위 집합 또는 전체 집합을 호출할 수 있는 권한을 부여합니다. 각 역할이 부여하는 API 엔드포인트에 대한 Atlas Search 설명은 Atlas Search Action 열을 참조하세요.

다음 MongoDB 데이터베이스 역할은지정된 Atlas Search 인덱스 권한 작업을 지원 .

작업 설명
데이터베이스 역할
Atlas Search 인덱스 권한 작업

Atlas Search 인덱스 보기

Atlas Search 인덱스 만들기

Atlas Search 인덱스 편집

Atlas Search 인덱스 삭제

자세한 내용은 기본 제공 역할 또는 특정 권한을 참조하세요.

다음 튜토리얼에서는 선택한 방법을 사용하여 Atlas Search 인덱스 생성하는 방법을 설명합니다.

sample_mflix.movies 컬렉션에 대한 인덱스 만드는 예시 튜토리얼을 보려면 Atlas Search 빠른 시작을 참조하세요. 쿼리 설정에 맞게 인덱스 정의하는 방법에 대한 개념적 개요는 인덱스 정의를 참조하세요.

Atlas CLI를 사용하여 만든 로컬 Atlas 배포와 함께 Atlas Search를 사용할 수도 있습니다. 자세한 내용은 로컬 Atlas 배포 만들기를 참조하세요.


언어 선택 드롭다운 메뉴를 사용하여 이 섹션에서 절차의 언어 설정하다.


Atlas Search API 사용하여 Atlas Search Atlas Search 인덱스 만들려면 다음을 수행합니다.

1

search/indexes 엔드포인트POST 요청을 보냅니다.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--include \
--request POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes" \
--data '
{
"collectionName": "<collection-name>",
"database": "<database-name>",
"name": "<index-name>",
"type": "search",
"definition":
{
"analyzer": "<analyzer-name>",
"searchAnalyzer": "<analyzer-name>",
"mappings": {
"dynamic": <boolean>,
"fields": { <field-definition> }
},
"numPartitions": <integer>,
"analyzers": [ {
<custom-analyzer-definition>
}
],
"storedSource": <boolean> | {
<stored-source-definition>
},
"synonyms": [
{
<synonym-mapping-definition>
}
]
}
}'

이 엔드포인트의 구문 및 매개변수에 대해 자세히 알아보려면 엔드포인트 생성하기를 참조하세요.

2

참고

컬렉션이 존재하지 않는 경우 Atlas는 인덱스를 생성하지 않지만 여전히 200 상태를 반환합니다.

Atlas CLI 사용하여 Atlas Search 인덱스 생성하려면 다음을 수행합니다.

Atlas CLI를 사용하여 클러스터에 대한 검색 인덱스를 생성하려면 다음 명령을 실행하세요.

atlas clusters search indexes create [indexName] [options]

명령 구문 및 매개변수에 대한 자세한 내용은 Atlas CLI 문서에서 Atlas 클러스터 검색 인덱스 만들기를 참조하십시오.

Atlas CLI를 사용하여 지정된 배포에 대한 검색 인덱스를 생성하려면 다음 명령을 실행하세요.

atlas deployments search indexes create [indexName] [options]

명령 구문 및 매개변수에 대해 자세히 알아보려면 검색 인덱스가 생성하는 Atlas 배포에 대한 Atlas CLI 설명서를 참조하세요.

Atlas CLI 사용하여 로컬 Atlas 배포서버 만드는 방법에 대해 자세히 학습 로컬 Atlas 배포서버 만들기를 참조하세요.

참조: 관련 링크

다음 예시는 구성 파일을 사용하여 비대화식 모드에서 atlas clusters 또는 atlas deployments 명령어를 사용하여 Atlas Search 인덱스를 생성하는 방법을 보여줍니다.

1
{
"collectionName": "movies",
"database": "sample_mflix",
"definition": {
"mappings": {
"dynamic": true
},
},
"name": "searchIndex"
}
2
  1. 다음 명령 중 하나를 실행합니다.

    클라우드 배포:

    atlas clusters search indexes create --file indexDef.json

    로컬 배포:

    atlas deployments search indexes create --file indexDef.json
  2. 배포서버를 지정하고 Enter를 누릅니다.

Atlas UI 사용하여 Atlas Search 인덱스 만들려면 다음을 수행합니다.

1

경고

탐색 개선 진행 중

현재 새롭고 향상된 탐색 환경을 출시하고 있습니다. 다음 단계가 Atlas UI 의 보기와 일치하지 않는 경우 미리 보기 설명서를 참조하세요.

  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.

  3. 아직 표시되지 않은 경우 사이드바에서 Clusters를 클릭합니다.

    Clusters(클러스터) 페이지가 표시됩니다.

2

사이드바, Data Explorer 또는 클러스터 세부 정보 페이지에서 Atlas Search 페이지로 이동할 수 있습니다.

  1. 사이드바에서 Services 제목 아래의 Atlas Search를 클릭합니다.

    클러스터가 없는 경우 Create cluster를 클릭하여 클러스터를 생성합니다. 자세히 알아보려면 클러스터 생성을 참조하세요.

  2. 프로젝트 에 클러스터가 여러 개 있는 경우 Select cluster 드롭다운에서 사용할 클러스터 선택한 다음 Go to Atlas Search을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. cluster의 Browse Collections 버튼을 클릭합니다.

  2. 데이터베이스를 확장하고 컬렉션을 선택합니다.

  3. 컬렉션의 Search Indexes 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. 클러스터 이름을 클릭합니다.

  2. Atlas Search 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

3
4

페이지에서 다음 항목을 선택한 후 Next를 클릭합니다.

Search Type

Atlas Search 인덱스 유형을 선택합니다.

Index Name and Data Source

다음 정보를 지정합니다.

  • Index Name: default

  • Database and Collection:

    • 데이터베이스 의 이름

    • 컬렉션 의 이름

Configuration Method

For a guided experience, select Visual Editor.

To edit the raw index definition, select JSON Editor.

참고

Atlas Search 인덱스 의 이름은 기본값 으로 default 으로 지정됩니다. 이 이름을 유지하면 해당 인덱스 연산자에 다른 index 옵션을 지정하지 않는 모든 Atlas Search 쿼리 대한 기본값 검색 인덱스 됩니다. 여러 인덱스를 생성하는 경우 인덱스 전체에서 일관적인 되고 설명이 포함된 명명 규칙을 유지하는 것이 좋습니다.

5

기본 인덱스 정의는 문서의 필드를 동적으로 매핑한 것이며 모든 컬렉션에서 작동합니다.

인덱스 정의를 사용자 지정하려면 다음 인덱스 구성을 검토 .

비주얼 편집기 필드
설명
필요성

Index Analyzer

컬렉션 데이터 인덱싱에 사용할 분석기를 지정합니다. 기본적으로 Atlas Search는 표준 분석기(lucene.standard)를 사용합니다.

analyzer JSON 설정에 해당합니다.

옵션

Search Analyzer

텍스트를 검색하기 전에 쿼리 텍스트에 적용할 분석기를 지정합니다. 이 필드를 생략하면 인덱스는 기본적으로 다음 순서로 분석기를 상속합니다.

  1. 지정된 경우 이 필드에 대한 analyzer 옵션입니다.

  2. 지정된 경우 인덱스 에 대한 searchAnalyzer 옵션입니다.

  3. 지정된 경우 인덱스 에 대한 analyzer 옵션입니다.

  4. lucene.standard 분석기입니다.

searchAnalyzer JSON 설정에 해당합니다.

옵션

Dynamic Mapping

필드의 동적 또는 정적 매핑을 지정합니다.

기본값 으로 동적 매핑이 활성화되어 있습니다. 동적 매핑을 비활성화하려면 dynamicOff로 설정하다 . 동적 매핑을 비활성화하는 경우 인덱스 할 필드를 지정해야 합니다.

동적 및 정적 매핑에 대해 자세히 학습 필드 매핑 정의를 참조하세요.

mappings.dynamic JSON 설정에 해당합니다.

필수 사항

필드 이름
설명
필요성

analyzer

컬렉션 데이터 인덱싱에 사용할 분석기를 지정합니다. 기본적으로 Atlas Search는 표준 분석기(lucene.standard)를 사용합니다.

옵션

searchAnalyzer

텍스트를 검색하기 전에 쿼리 텍스트에 적용할 분석기를 지정합니다. 이 필드를 생략하면 인덱스는 기본적으로 다음 순서로 분석기를 상속합니다.

  1. 지정된 경우 이 필드에 대한 analyzer 옵션입니다.

  2. 지정된 경우 인덱스 에 대한 searchAnalyzer 옵션입니다.

  3. 지정된 경우 인덱스 에 대한 analyzer 옵션입니다.

  4. lucene.standard 분석기입니다.

옵션

mappings.dynamic

필드의 동적 또는 정적 매핑을 지정합니다. 동적 매핑을 비활성화하려면 "dynamic":false로 설정하다. 기본값 으로 동적 매핑이 활성화되어 있습니다. 동적 매핑을 비활성화하는 경우 인덱스 할 필드를 지정해야 합니다. 동적 및 정적 매핑에 대해 자세히 학습 인덱스 참조를 확인하세요.

필수 사항

이러한 인덱스 정의 설정에 대해 자세히 학습 인덱스 참조를 확인하세요.

기본 구성에 만족하는 경우 건너뜁니다. Atlas Search 인덱스를 세분화하려면 다음 단계로 진행하세요.

6
  1. 다음 설정을 변경하려면 Refine Your Index을 클릭합니다.

    필드 이름
    설명
    필요성

    Field Mappings

    1}Dynamic Mapping Index Configurations 섹션의 이 비활성화된 경우 필수입니다.

    인덱스 할 필드를 지정합니다.

    1. Add Field Mapping 을 클릭하여 Add Field Mapping 창을 엽니다.

    2. 필드에 대해 다음 정보를 지정합니다.

      • Field name - 인덱싱할 필드의 이름입니다.

      • Data Type - 필드 데이터 유형입니다. 지원되는 데이터 유형과 해당 옵션에 대해 자세히 알아보려면 데이터 유형 을 참조하세요.

    3. (선택 사항) 추가 속성을 지정합니다.

      추가 구성 옵션 표가 Add Field Mapping 창 에 나타납니다. 이러한 속성은 마지막 단계에서 선택한 데이터 유형 에 따라 달라집니다.

      지원되는 데이터 유형과 해당 옵션에 대해 자세히 알아보려면 데이터 유형 을 참조하세요.

    4. (선택 사항) 다중 필드 추가합니다.

      필드 인덱스 할 대체 필드 분석기 구성하려면 Add Multi Field 을 클릭합니다. 자세한 학습 은 다중 분석기를 참조하세요.

    5. 필드를 추가하려면 Add을 클릭합니다.

      Actions 열의 필드 에 대한 타원(...) 아이콘을 클릭하여 다음을 수행할 수 있습니다.

      • 구성을 수정하려면 Edit 을 클릭합니다.

      • 필드 에 대한 추가 데이터 유형을 구성하려면 Add Data Type 를 클릭합니다.

      • 인덱스 에서 필드 제거 하려면 Delete 을 클릭합니다.

    필드 매핑 정의에 대해 자세히 학습 인덱스 참조를 참조하세요.

    mappings.fields JSON 설정에 해당합니다.

    조건부

    Stored Source Fields

    쿼리 시간 조회를 위해 Atlas Search에 저장 필드를 지정합니다. 지원되는 모든 데이터 유형 의 필드를 Atlas Search에 저장 수 있습니다.

    필드 저장에 관한 자세한 사항은 Atlas 검색 인덱스에서 저장된 소스 필드 정의를 참조하십시오.

    storedSource JSON 설정에 해당합니다.

    옵션

    Synonyms Mappings

    인덱스 에 사용할 동의어 매핑을 지정합니다.

    동의어 매핑을 사용하여 동일한 분석기 로 분석된 필드만 쿼리 할 수 있습니다.

    동의어 매핑에 대해 자세히 학습 Atlas Search 인덱스에서 동의어 매핑 정의를 참조하세요.

    synonyms JSON 설정에 해당합니다.

    선택 사항.

    Index Partitions

    필드 객체가 2.1 십억을 초과하는 경우 사용할 파티션 수입니다.

    numPartitions JSON 설정에 해당합니다.

    선택 사항.

  2. Save Changes를 클릭합니다.

  1. 인덱스에 다음 설정 중 하나를 추가합니다.

    필드 이름
    설명
    필요성

    mappings.fields

    mappings.dynamicfalse인 경우 필요합니다.

    인덱싱할 필드를 지정합니다. 자세한 내용은 필드 매핑 정의를 참조하세요.

    조건부

    storedSource

    쿼리 시간 조회를 위해 Atlas Search에 저장 필드를 지정합니다. 지원되는 모든 데이터 유형 의 필드를 Atlas Search에 저장 수 있습니다.

    필드 저장에 관한 자세한 사항은 Atlas 검색 인덱스에서 저장된 소스 필드 정의를 참조하십시오.

    옵션

    synonyms

    인덱스 에 사용할 동의어 매핑을 지정합니다.

    동의어 매핑을 사용하여 동일한 분석기 로 분석된 필드만 쿼리 할 수 있습니다.

    동의어 매핑에 대해 자세히 학습 Atlas Search 인덱스에서 동의어 매핑 정의를 참조하세요.

    옵션

    numPartitions

    필드 객체가 2.1 십억을 초과하는 경우 사용할 파티션 수입니다.

    선택 사항.

    이러한 인덱스 정의 설정에 대해 자세히 학습 인덱스 참조를 확인하세요.

  2. Next를 클릭합니다.

7

참고

기본값 인덱스 정의는 초안으로 저장할 수 없습니다. 를 사용하고 Visual Editor 인덱스 정의에 정적 매핑이 포함되어 있는 경우 인덱스 정의를 초안으로 저장할 수 있습니다.

  1. Cancel를 클릭합니다.

  2. Save Draft 또는 Delete Draft를 클릭합니다.

    중요

    보류 중인 인덱스 초안이 있는 경우 새 인덱스를 만들 수 없습니다.

    자세히 학습 Atlas Search 인덱스 초안 재개 또는 삭제를 참조하세요.

8

Atlas는 인덱스가 구축 중임을 알리기 위해 토스트(간단한 비대화형 알림)를 표시합니다.

9

새로 생성된 인덱스가 Atlas Search 탭에 나타납니다. 인덱스가 빌드되는 동안 Status 필드는 Build in Progress를 읽습니다. 인덱스 빌드가 완료되면 Status 필드에 Active가 표시됩니다.

참고

컬렉션이 클수록 인덱스를 생성하는 데 시간이 더 오래 걸립니다. 인덱스 빌드가 완료되면 이메일 알림을 받게 됩니다.

를 사용하여 Atlas Search 인덱스 생성하려면 mongosh 다음을 수행합니다.

1

자세한 내용은 mongosh를 통한 연결을 참조하세요.

2

db.collection.createSearchIndex() 메서드를 사용합니다.

명령의 구문은 다음과 같습니다. 인덱스 이름을 생략하면 Atlas Search 인덱스 이름을 default으로 지정합니다. 자세한 학습 은 인덱스 참조를 참조하세요.

db.<collection>.createSearchIndex(
"<index-name>",
{
/* search index definition */
}
)

예시

movies 컬렉션의 필드를 동적으로 인덱싱하는 example-index라는 인덱스를 생성하려면 다음 명령을 실행하세요.

db.movies.createSearchIndex(
"example-index",
{ mappings: { dynamic: true } }
)
example-index

MongoDB Compass 사용하여 Atlas Search 인덱스 생성하려면 다음을 수행합니다.

1

Compass 열고 Atlas cluster 에 연결합니다. 자세한 지침은 Compass 통한 연결을 참조하세요.

2

Database 화면에서 데이터베이스 이름을 클릭한 다음 컬렉션 이름을 클릭합니다.

3
  1. Indexes 탭을 클릭한 다음 Search Indexes을(를) 선택합니다.

  2. Create Index를 클릭하여 인덱스 생성 대화 상자를 엽니다.

  3. 인덱스의 이름을 지정합니다.

    Atlas Search 인덱스 의 이름은 기본값 으로 default 으로 지정됩니다. 이 이름을 유지하면 해당 인덱스 연산자에 다른 index 옵션을 지정하지 않는 모든 Atlas Search 쿼리 대한 기본값 검색 인덱스 됩니다. 여러 인덱스를 생성하는 경우 인덱스 전체에서 일관적인 되고 설명이 포함된 명명 규칙을 유지하는 것이 좋습니다.

  4. JSON Atlas Search 인덱스 정의를 지정합니다.

    1{
    2 "analyzer": "<analyzer-for-index>",
    3 "searchAnalyzer": "<analyzer-for-query>",
    4 "mappings": {
    5 "dynamic": <boolean>,
    6 "fields": { <field-definition> }
    7 },
    8 "numPartitions": <integer>,
    9 "analyzers": [ <custom-analyzer> ],
    10 "storedSource": <boolean> | {
    11 <stored-source-definition>
    12 },
    13 "synonyms": [
    14 {
    15 <synonym-mapping-definition>
    16 }
    17 ]
    18}
    19
  5. Create Search Index를 클릭합니다.

Atlas Search 인덱스를 생성하기 위해 C 드라이버를 사용하려면 애플리케이션 내에서 검색 인덱스를 정의하고 mongoc_collection_command_simple() 메서드를 호출하세요.

참고

Atlas Search 인덱스 관리 방법은 비동기적으로 실행됩니다. 드라이버 메서드는 성공적으로 실행되었는지 확인하기 전에 반환될 수 있습니다. 검색 인덱스의 현재 상태를 확인하려면 $listSearchIndexes 파이프라인 단계와 함께 집계 작업을 실행합니다.

1
2

다음 샘플 애플리케이션 createSearchIndexes 명령을 지정하여 검색 인덱스 정의합니다. 그런 다음 애플리케이션 명령과 검색 인덱스 정보를 BSON 으로 변환하고 이 정보를 mongoc_collection_command_simple() 메서드에 전달하여 검색 인덱스 생성합니다. 자세한 학습 은 인덱스 참조를 참조하세요.

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the new index
const char *cmd_str = BSON_STR({
"createSearchIndexes" : "<collectionName>",
"indexes" : [ {
"name" : "<indexName>",
"definition" : {
"analyzer": "<indexAnalyzer>",
"searchAnalyzer": "<queryAnalyzer>",
"mappings": {
"dynamic": <boolean>,
"fields": { <fieldDefinition> }
},
"numPartitions": <integer>,
"analyzers": [ <customAnalyzer> ],
"storedSource": <boolean> | {
<storedSourceDefinition>
},
"synonyms": [
{
<synonymMappingDefinition>
}
]
}
} ]
});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Create the Atlas search index by running the command
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run createSearchIndexes: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Index created!\n");
cleanup:
mongoc_collection_destroy (collection);
mongoc_client_destroy (client);
mongoc_database_destroy (database);
bson_destroy (&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}

다음 샘플 애플리케이션 createSearchIndexes 명령을 사용하여 여러 검색 인덱스를 정의합니다. 그런 다음 애플리케이션 명령과 검색 인덱스 정보를 BSON 으로 변환하고 이 정보를 mongoc_collection_command_simple() 메서드에 전달하여 검색 인덱스 생성합니다. 자세한 학습 은 인덱스 참조를 참조하세요.

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the new indexes
const char *cmd_str = BSON_STR({
"createSearchIndexes" : "<collectionName>",
"indexes" : [{
// Add your search index definition fields here
"name" : "<firstIndexName>"
},
{
// Add your search index definition fields here
"name" : "<secondIndexName>"
}]
});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Create the Atlas search indexes by running the command
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run createSearchIndexes: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Indexes created!\n");
cleanup:
mongoc_collection_destroy (collection);
mongoc_client_destroy (client);
mongoc_database_destroy (database);
bson_destroy (&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
  • Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

  • 인덱스를 작성하려는 데이터베이스 및 컬렉션입니다.

  • 인덱스의 이름입니다. 인덱스 이름을 생략하는 경우 Atlas Search는 인덱스 이름을 default으로 지정합니다.

  • 검색 인덱스 정의입니다. 자세한 학습 은 인덱스 참조를 참조하세요.

4
gcc -o create-index create-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./create-index

Atlas Search 인덱스를 생성하기 위해 C++ 드라이버를 사용하려면 애플리케이션 내에서 검색 인덱스를 정의하고 create_one() 메서드를 호출하세요.

참고

Atlas 검색 인덱스 관리 방법은 비동기적으로 실행됩니다. 드라이버 메서드는 성공적으로 실행되었는지 확인하기 전에 반환될 수 있습니다. 검색 인덱스의 현재 상태를 확인하려면 검색 인덱스 뷰 인스턴스에서 list() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션 검색 인덱스 이름과 정의를 search_index_model() 메서드에 전달하여 컬렉션 의 필드를 동적으로 인덱스 . 그런 다음 애플리케이션 검색 인덱스 사양을 create_one() 메서드에 전달하여 검색 인덱스 생성합니다. 자세한 학습 은 인덱스 참조를 참조하세요.

#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::make_document;
using namespace mongocxx;
int main()
{
try
{
// Connect to your Atlas deployment
mongocxx::instance instance{};
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Create an index model with your index name and definition
auto siv = collection.search_indexes();
auto name = "<indexName>";
auto definition = make_document(kvp("mappings", make_document(kvp("dynamic", true))));
auto model = search_index_model(name, definition.view());
// Create the search index
siv.create_one(model);
std::cout << "Index created!" << std::endl;
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}

한 번에 여러 개의 Atlas Search 인덱스를 만들 수도 있습니다. 만들려는 각 검색 인덱스에 대해 검색 인덱스 사양을 search_index_model() 메서드에 전달합니다. 그런 다음 각 검색 인덱스를 벡터에 추가하고 벡터를 create_many() 메서드에 전달하여 검색 인덱스를 생성합니다.

#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::make_document;
using namespace mongocxx;
int main()
{
try
{
// Connect to your Atlas deployment
mongocxx::instance instance{};
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Create index models and add them to a vector
auto siv = collection.search_indexes();
std::vector<search_index_model> models;
auto name1 = "<firstIndexName>";
auto definition1 = make_document(/* Add search index definition fields here */);
auto model1 = search_index_model(name1, definition1.view());
models.push_back(model1);
auto name2 = "<secondIndexName>";
auto definition2 = make_document(/* Add search index definition fields here */);
auto model2 = search_index_model(name2, definition2.view());
models.push_back(model2);
// Create the search indexes
siv.create_many(models);
std::cout << "Indexes created!" << std::endl;
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
  • Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

  • 인덱스를 작성하려는 데이터베이스 및 컬렉션입니다.

  • 인덱스의 이름입니다. 인덱스 이름을 생략하는 경우 Atlas Search는 인덱스 이름을 default으로 지정합니다.

  • 검색 인덱스 정의입니다. 자세한 학습 은 인덱스 참조를 참조하세요.

4
g++ -o create-index create-index.cpp $(pkg-config --cflags --libs libmongocxx)
./create-index

.NET/C# 드라이버로 Atlas Search 인덱스를 생성하려면 다음을 수행합니다.

  1. 인덱스를 정의하는 BsonDocument를 생성합니다.

  2. BsonDocumentCreateOne() 또는 CreateOneAsync() 메서드에 전달하세요.

1
  1. 다음 명령을 실행하여 csharp-create-index라는 새 디렉토리를 생성합니다.

    mkdir csharp-create-index
  2. 다음 명령을 실행하여 새 디렉토리로 변경합니다.

    cd csharp-create-index
  3. 다음 명령을 실행하여 프로젝트를 초기화합니다.

    dotnet new console
2

다음 명령을 실행합니다:

dotnet add package MongoDB.Driver
3

SearchIndexes.CreateOne 명령을 사용하여 Atlas Search 인덱스 정의하는 다음 예시 애플리케이션 에서 자리 표시자 값을 바꿉니다.

설명

<connection-string>

Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

<databaseName>

인덱스를 생성하려는 데이터베이스입니다.

<collectionName>

인덱스를 생성하려는 컬렉션입니다.

<IndexName>

인덱스의 이름입니다. 인덱스 이름을 생략하는 경우 Atlas Search는 인덱스 이름을 default으로 지정합니다.

<IndexDefinition>

인덱스 의 정의입니다. 인덱스 정의 구문에 대해 학습 인덱스 참조를 확인하세요.

1using MongoDB.Bson;
2using MongoDB.Driver;
3
4// connect to your Atlas deployment
5var uri = "<connection-string>";
6
7var client = new MongoClient(uri);
8
9var db = client.GetDatabase("<databaseName>");
10var collection = db.GetCollection<BsonDocument>("<collectionName>");
11
12// define your Atlas Search index
13var index = new BsonDocument
14{
15 { "mappings", new BsonDocument
16 {
17 { "dynamic", true }
18 }
19 }
20};
21
22var result = collection.SearchIndexes.CreateOne(index, "<indexName>");
23Console.WriteLine(result);

SearchIndexes.CreateMany 명령을 사용하여 Atlas Search 인덱스 정의하는 다음 예시 애플리케이션 에서 자리 표시자 값을 바꿉니다.

설명

<connection-string>

Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

<databaseName>

인덱스를 생성하려는 데이터베이스입니다.

<collectionName>

인덱스를 생성하려는 컬렉션입니다.

<firstIndexName>

첫 번째 인덱스의 이름입니다.

<lastIndexName>

마지막 인덱스의 이름입니다.

<IndexDefinition>

인덱스 의 정의입니다. 인덱스 정의 구문에 대해 학습 인덱스 참조를 확인하세요.

1using MongoDB.Bson;
2using MongoDB.Driver;
3
4// connect to your Atlas deployment
5var uri = "<connection-string>";
6
7var client = new MongoClient(uri);
8
9var db = client.GetDatabase("<databaseName>");
10var collection = db.GetCollection<BsonDocument>("<collectionName>");
11
12// define your Atlas Search indexes
13var indexes = new List<CreateSearchIndexModel>
14{
15 new CreateSearchIndexModel(
16 "<firstIndexName>",
17 new BsonDocument
18 {
19 <IndexDefinition>// search index definition fields
20 }
21 ),
22 ...
23 new CreateSearchIndexModel(
24 "<lastIndexName>",
25 new BsonDocument
26 {
27 <IndexDefinition> // search index definition fields
28 }
29 )
30};
31
32var result = collection.SearchIndexes.CreateMany(indexes);
4

다음 명령을 사용하여 프로젝트를 실행합니다.

dotnet run csharp-create-index.csproj
default

API 문서

이 페이지의 메서드에 대한 자세한 내용은 .NET/C# 드라이버의 API 설명서를 참조하세요.

Java 드라이버 사용하여 Atlas Search 인덱스 생성하려면 검색 인덱스 정의하는 문서 구성한 다음 createSearchIndex() 또는 createSearchIndexes() 메서드에 문서 전달합니다.

참고

Atlas 검색 인덱스 관리 방법은 비동기적으로 실행됩니다. 드라이버 메서드는 성공적으로 실행되었는지 확인하기 전에 반환될 수 있습니다. 인덱스의 현재 상태를 확인하려면 listSearchIndexes() 메서드를 호출합니다.

1
2

다음 샘플 애플리케이션 컬렉션 의 필드를 동적으로 인덱스 하는 검색 인덱스 정의한 다음 createSearchIndex() 메서드를 실행하여 인덱스 생성합니다. 자세한 학습 은 인덱스 참조를 참조하세요.

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
public class CreateIndex {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("<databaseName>");
MongoCollection<Document> collection = database.getCollection("<collectionName>");
Document index = new Document("mappings",
new Document("dynamic", true));
collection.createSearchIndex("<index-name>", index);
}
}
}

다음 샘플 애플리케이션을 사용하여 여러 Atlas Search 인덱스를 한 번에 생성할 수 있습니다. 이를 위해 생성하려는 각 검색 인덱스에 대한 문서를 작성한 후 해당 문서들을 배열로 createSearchIndexes() 메서드에 전달하세요.

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.SearchIndexModel;
import org.bson.Document;
import java.util.Arrays;
public class CreateIndex {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("<databaseName>");
MongoCollection<Document> collection = database.getCollection("<collectionName>");
SearchIndexModel indexOne = new SearchIndexModel("<first-index-name>",
new Document(
// search index definition fields
));
SearchIndexModel indexTwo = new SearchIndexModel("<second-index-name>",
new Document(
// search index definition fields
));
collection.createSearchIndexes(Arrays.asList(indexOne, indexTwo));
}
}
}
3
  • Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

  • 인덱스를 작성하려는 데이터베이스 및 컬렉션입니다.

  • 인덱스의 이름입니다. 인덱스 이름을 생략하는 경우 Atlas Search는 인덱스 이름을 default로 지정합니다.

  • 검색 인덱스 정의하는 필드입니다. 자세한 학습 은 인덱스 참조를 참조하세요.

4
javac CreateIndex.java
java CreateIndex

노드 드라이버를 통해 Atlas Search 인덱스를 생성하려면 다음을 수행하세요.

  1. 애플리케이션에서 검색 인덱스를 정의합니다.

  2. createSearchIndex 또는 createSearchIndexes 헬퍼 메서드를 실행합니다.

1
2

createSearchIndex 명령을 사용하여 Atlas Search 인덱스 정의하는 create-index.js 예시 애플리케이션 에서 자리 표시자 값을 바꿉니다.

설명

<connectionString>

Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

<databaseName>

인덱스를 생성하려는 데이터베이스입니다.

<collectionName>

인덱스를 생성하려는 컬렉션입니다.

<indexName>

인덱스의 이름입니다. 인덱스 이름을 생략하면 Atlas Search에서 인덱스 이름을 default 으로 지정합니다.

<IndexDefinition>

인덱스 의 정의입니다. 인덱스 정의 구문에 대해 학습 인덱스 참조를 확인하세요.

create-index.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connectionString>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// define your Atlas Search index
const index = {
name: "<indexName>",
definition: {
/* search index definition fields */
<indexDefinition>
}
}
// run the helper method
const result = await collection.createSearchIndex(index);
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);
설명

<connectionString>

Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

<databaseName>

인덱스를 생성하려는 데이터베이스입니다.

<collectionName>

인덱스를 생성하려는 컬렉션입니다.

<indexName>

인덱스의 이름입니다. 인덱스 이름을 생략하면 Atlas Search에서 인덱스 이름을 default 으로 지정합니다.

<IndexDefinition>

인덱스 의 정의입니다. 인덱스 정의 구문에 대해 학습 인덱스 참조를 확인하세요.

createSearchIndexes 명령을 사용하여 Atlas Search 인덱스 정의하는 create-index.js 예시 애플리케이션 에서 자리 표시자 값을 바꿉니다.

create-index.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// define an array of Atlas Search indexes
const indexes = [
{
name: "<first-index-name>",
definition: {
/* search index definition fields */
}
},
...
{
name: "<last-index-name>",
definition: {
/* search index definition fields */
}
}
]
// run the helper method
const result = await collection.createSearchIndexes(indexes);
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);
3

다음 명령을 사용하세요.

node create-index.js
<index-name>

Python 드라이버를 사용하여 Atlas Search 인덱스를 생성하려면, 애플리케이션에서 검색 인덱스를 정의하고 create_search_index() 메소드를 호출하세요.

참고

Atlas 검색 인덱스 관리 방법은 비동기적으로 실행됩니다. 드라이버 메서드는 성공적으로 실행되었는지 확인하기 전에 반환될 수 있습니다. 검색 인덱스의 현재 상태를 확인하려면 컬렉션에서 list_search_indexes() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션 컬렉션 의 필드를 동적으로 인덱스 하는 검색 인덱스 정의합니다. 그런 다음 애플리케이션 컬렉션 에서 create_search_index() 메서드를 호출하여 검색 인덱스 생성합니다. 자세한 학습 은 인덱스 참조를 참조하세요.

from pymongo.mongo_client import MongoClient
from pymongo.operations import SearchIndexModel
def create_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Create your index model, then create the search index
search_index_model = SearchIndexModel(
definition={
"mappings": {
"dynamic": True
},
},
name="<indexName>",
)
result = collection.create_search_index(model=search_index_model)
print(result)

한 번에 여러 개의 Atlas Search 인덱스를 생성할 수도 있습니다. 애플리케이션 에서 검색 인덱스 배열 을 정의합니다. 그런 다음 배열을 create_search_indexes() 메서드에 매개변수로 전달합니다.

from pymongo.mongo_client import MongoClient
from pymongo.operations import SearchIndexModel
def create_indexes():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Create your index models and add them to an array
first_model = SearchIndexModel(
definition={
# Add search index definition fields here
},
name="<firstIndexName>",
)
second_model = SearchIndexModel(
definition={
# Add search index definition fields here
},
name="<secondIndexName>",
)
idx_models = [first_model, second_model]
# Create the search indexes
result = collection.create_search_indexes(models=idx_models)
print(result)
3
  • Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

  • 인덱스를 작성하려는 데이터베이스 및 컬렉션입니다.

  • 인덱스의 이름입니다. 인덱스 이름을 생략하는 경우 Atlas Search는 인덱스 이름을 default으로 지정합니다.

  • 검색 인덱스 정의입니다. 자세한 학습 은 인덱스 참조를 참조하세요.

4
python create_index.py

Atlas Search 인덱스 생성하면 Atlas Search 페이지에 Atlas Search 인덱스에 대한 정보가 표시됩니다.Status 열에는 클러스터 의 프라이머리 노드 에 있는 인덱스 의 현재 상태 표시됩니다. 자세히 학습 인덱스 상태 검토를 참조하세요.

경고

이미 Atlas Search 인덱스가 있는 컬렉션을 샤드하는 경우, 컬렉션이 샤드에 표시되기 시작할 때 잠시 동안 쿼리 중단 시간이 발생할 수 있습니다. 또한 이미 샤드된 컬렉션에 대한 샤드를 추가하고 Atlas Search 인덱스가 포함된 경우, 추가된 샤드에서 초기 동기화 프로세스가 완료될 때까지 해당 컬렉션에 대한 검색 쿼리가 실패합니다. 자세한 내용은 초기 동기화 프로세스를 참조하세요.


언어 선택 드롭다운 메뉴를 사용하여 이 섹션에서 절차의 언어 설정하다.


Atlas Search API 사용하여 Atlas Search 인덱스 조회 하려면 다음을 수행합니다.

1

원하는 Atlas Search 인덱스의 고유 ID 또는 이름을 search/indexes/ 엔드포인트로 포함하여 GET 요청을 전송합니다.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{indexId}"

각 엔드포인트의 구문 및 매개변수에 대한 자세한 내용은 이름으로 가져오기ID로 가져오기를 참조하세요.

2

컬렉션의 모든 Atlas Search 인덱스를 조회하려면 다음을 수행하세요.

1

인덱스를 검색하려는 컬렉션 이름을 사용하여 search/indexes/ 엔드포인트GET 요청을 보냅니다.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{databaseName}/{collectionName}"
2

클러스터의 모든 Atlas Search 인덱스를 조회하려면 다음을 수행하세요.

1

인덱스를 조회할 클러스터의 이름과 함께 search/indexes/ 엔드포인트GET 요청을 보냅니다.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes"
2

Atlas CLI를 사용하여 클러스터의 모든 검색 인덱스를 나열하려면 다음 명령을 실행하세요.

atlas clusters search indexes list [options]

Atlas CLI를 사용하여 지정한 검색 인덱스에 대한 세부 정보를 반환하려면 다음 명령을 실행하세요.

atlas clusters search indexes describe <indexId> [options]

이전 명령의 구문 및 매개변수에 대해 자세히 알아보려면 Atlas CLI 클러스터 Atlas Atlas Search 인덱스 목록 Atlas 및 cluster Atlas Search 인덱스 설명 에 대한설명서를 참조하세요.

참조: 관련 링크

Atlas CLI를 사용하여 지정된 배포에 대한 지정된 검색 인덱스를 설명하려면 다음 명령을 실행하세요.

atlas deployments search indexes describe [indexId] [options]

Atlas CLI를 사용하여 지정된 배포에 대한 모든 검색 인덱스를 나열하려면 다음 명령을 실행하세요.

atlas deployments search indexes list [options]

이전 명령의 구문 및 매개변수에 대해 자세히 알아보려면 Atlas 배포 검색 인덱스 설명Atlas 배포 검색 인덱스 목록에 대한 Atlas CLI 문서를 참조하세요.

참조: 관련 링크

Atlas UI Atlas Search 페이지를 보려면 다음과 같이 하세요:

1

경고

탐색 개선 진행 중

현재 새롭고 향상된 탐색 환경을 출시하고 있습니다. 다음 단계가 Atlas UI 의 보기와 일치하지 않는 경우 미리 보기 설명서를 참조하세요.

  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.

  3. 아직 표시되지 않은 경우 사이드바에서 Clusters를 클릭합니다.

    Clusters(클러스터) 페이지가 표시됩니다.

2

사이드바, Data Explorer 또는 클러스터 세부 정보 페이지에서 Atlas Search 페이지로 이동할 수 있습니다.

  1. 사이드바에서 Services 제목 아래의 Atlas Search를 클릭합니다.

    클러스터가 없는 경우 Create cluster를 클릭하여 클러스터를 생성합니다. 자세히 알아보려면 클러스터 생성을 참조하세요.

  2. 프로젝트 에 클러스터가 여러 개 있는 경우 Select cluster 드롭다운에서 사용할 클러스터 선택한 다음 Go to Atlas Search을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. cluster의 Browse Collections 버튼을 클릭합니다.

  2. 데이터베이스를 확장하고 컬렉션을 선택합니다.

  3. 컬렉션의 Search Indexes 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. 클러스터 이름을 클릭합니다.

  2. Atlas Search 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

Atlas Search 페이지에는 다음 열에서 프로젝트 의 기존 Atlas Search 인덱스 각각을 설명하는 표가 포함되어 있습니다.

설명

Database

컬렉션이 포함된 데이터베이스의 이름입니다.

Collection

인덱싱된 컬렉션의 이름입니다.

Index Name

인덱스의 이름입니다.

Status

클러스터 의 프라이머리 노드 에 있는 인덱스 상태입니다. 자세히 학습 Atlas Search 인덱스 상태를 참조하세요.

Queryable

컬렉션이 인덱스를 사용하여 쿼리 가능한지 여부를 나타내는 아이콘. 값은 다음 아이콘 중 하나일 수 있습니다.

  • - 컬렉션을 쿼리 하는 데 사용할 수 있는 인덱스.

  • X - 컬렉션을 쿼리하는 데 사용할 수 없는 인덱스.

Type

인덱스의 유형입니다. 값은 다음 유형의 인덱스 중 하나일 수 있습니다.

Index Fields

인덱싱된 필드. 동적 매핑을 활성화한 경우 값은 dynamic입니다. 정적 매핑의 경우 열에는 인덱싱된 모든 필드가 표시됩니다.

Documents

클러스터의 프라이머리 또는 검색 노드에서 인덱스를 구축하는 동안과 구축 후에 컬렉션의 총 문서 수 중 인덱싱된 문서의 대략적인 수와 백분율입니다.

Size

인덱스의 크기입니다.

Actions

인덱스에서 수행할 수 있는 작업:

  • 컬렉션을 쿼리하기 위해 Search Tester로 이동하려면 Query를 클릭합니다.

  • 아이콘을 클릭하고 인덱스에 수행할 다음 작업 중 하나를 선택합니다.

    • Visual Editor 또는 JSON Editor를 사용하여 인덱스를 편집합니다.

    • 인덱스에 대한 쿼리 분석을 확인합니다.

    • 인덱스를 삭제합니다.

기본값 으로 Atlas 데이터베이스 이름을 기준으로 인덱스를 정렬한 다음 컬렉션 이름을 기준으로 인덱스를 정렬합니다. 여러 열을 기준으로 정렬하려면 Shift 키를 누르고 인덱스 목록을 다중 정렬하려는 순서대로 열 이름을 클릭합니다.

이 표에서 다음 섹션으로 이동하여 각 인덱스 에 대한 자세한 내용을 확인할 수 있습니다.

Atlas Search 페이지에서 Index Overview 페이지로 이동하려면 Index Name 열에서 보려는 인덱스의 이름을 클릭합니다. 각 인덱스에 대해 Index Overview 페이지에는 인덱스의 네임스페이스 와 인덱스 정의에 지정된 다음 구성이 표시됩니다.

설명

인덱스 분석기

검색 인덱스 구축할 때 텍스트가 처리되고 토큰화되는 방식을 지정하는 선택된 텍스트 분석기 .

검색 분석기

검색 쿼리의 텍스트가 처리되고 토큰화되는 방식을 지정하는 선택된 텍스트 분석기 입니다.

동적 매핑

필드 매핑에 동적 또는 정적 매핑 을 활성화했는지 여부를 나타내는 부울입니다.

필드 매핑

필드 이름, 데이터 유형 및 개별 필드 에 대한 동적 매핑 활성화 여부를 포함한 지정된 필드 매핑

저장된 소스 필드

정의된 모든 저장된 소스 필드

동의어 매핑

동등한 단어에 대해 정의된 동의어 매핑

mongosh를 통해 Atlas Search 인덱스를 조회하려면 db.collection.getSearchIndexes() 메서드를 사용합니다.

명령은 다음과 같은 구문을 가집니다. 인덱스 이름을 생략하는 경우, Atlas Search는 컬렉션의 모든 인덱스를 반환합니다.

db.<collection>.getSearchIndexes("<index-name>")

다음 명령은 movies 컬렉션에서 default라는 검색 인덱스를 조회합니다. 결과는 예시 출력과 유사해야 합니다.

db.movies.getSearchIndexes("default")
[
{
id: '648b4ad4d697b73bf9d2e5e0',
name: 'default',
status: 'READY',
queryable: true,
latestDefinition: { mappings: { dynamic: true } }
}
]
1

Compass 열고 Atlas cluster 에 연결합니다. 자세한 지침은 Compass 통한 연결을 참조하세요.

2

Database 화면에서 데이터베이스 이름을 클릭한 다음 컬렉션 이름을 클릭합니다.

3

이 페이지에는 다음이 표시됩니다.

열 이름
설명

Name and Fields

인덱스 의 이름 및 인덱싱된 필드의 이름입니다.

Type

인덱스 유형입니다. 값은 Search 또는 Vector Search일 수 있습니다.

Status

인덱스 의 상태입니다. 자세히 학습 인덱스 상태 검토를 참조하세요.

작업

인덱스 위로 마우스를 가져가면 인덱스 에 대해 수행할 수 있는 작업입니다. 다음과 같은 조치를 취할 수 있습니다.

  • 애그리게이션 - Aggregations 탭 으로 전환하여 인덱스 사용하여 쿼리를 실행 .

  • - 원시 JSON 형식으로 인덱스 편집합니다.

  • - 인덱스 삭제 .

C 드라이버를 사용하여 Atlas Search 인덱스를 조회하려면 mongoc_collection_aggregate() 메서드를 사용하여 $listSearchIndexes 단계를 포함하는 집계 파이프라인을 만듭니다.

1
2

다음 샘플 애플리케이션에서는 집계 파이프라인의 $listSearchIndexes 단계를 지정합니다. 그런 다음 애플리케이션은 파이프라인과 대상 컬렉션을 mongoc_collection_aggregate() 메서드에 전달합니다. 이 메서드는 코드가 각 Atlas Search 인덱스에 액세스하여 인쇄하는 커서를 반환합니다.

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
bson_t pipeline = BSON_INITIALIZER;
mongoc_cursor_t *cursor = NULL;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Create an aggregation pipeline with the $listSearchIndexes stage
const char *pipeline_str =
BSON_STR ({"pipeline" : [ {"$listSearchIndexes" : {}} ]});
// Convert your aggregation pipeline to BSON
if (!bson_init_from_json(&pipeline, pipeline_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Run the aggregation operation and iterate through the indexes returned
cursor = mongoc_collection_aggregate (collection,
MONGOC_QUERY_NONE,
&pipeline,
NULL,
NULL);
const bson_t *got;
char *str;
while (mongoc_cursor_next (cursor, &got)) {
str = bson_as_canonical_extended_json (got, NULL);
printf ("%s\n", str);
bson_free (str);
}
if (mongoc_cursor_error (cursor, &error)) {
fprintf (stderr, "Failed to iterate all documents: %s\n", error.message);
ok = false;
goto cleanup;
}
cleanup:
mongoc_cursor_destroy(cursor);
mongoc_collection_destroy(collection);
mongoc_database_destroy(database);
mongoc_client_destroy(client);
bson_destroy(&pipeline);
bson_destroy(&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
4
gcc -o view-index view-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./view-index

C++ 드라이버를 사용하여 Atlas Search 인덱스를 검색하려면 검색 인덱스 뷰에서 list() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션에서는 대상 컬렉션에서 search_indexes() 메서드를 사용하여 검색 인덱스 뷰를 인스턴스화합니다. 그런 다음, 애플리케이션은 뷰에서 list() 메서드를 호출합니다. 이 메서드는 코드가 각 Atlas Search 인덱스에 액세스하여 인쇄하는 커서를 반환합니다.

#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using namespace mongocxx;
int main()
{
mongocxx::instance instance{};
try
{
// Connect to your Atlas deployment
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Access and print the indexes in your collection
auto siv = collection.search_indexes();
auto cursor = siv.list();
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
};
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
4
g++ -o view-index view-index.cpp $(pkg-config --cflags --libs libmongocxx)
./view-index

.NET/C# 드라이버를 사용하여 Atlas Search 인덱스를 조회하려면 List() 또는 ListAsync() 메서드를 사용합니다.

다음 샘플 애플리케이션은 컬렉션의 인덱스를 반환합니다. 다음 값을 지정합니다.

참고

List() 메서드는 인덱스 대신 커서를 반환합니다. 인덱스에 액세스하려면 MoveNext() 메서드와 같은 커서 패러다임을 사용하세요.

Program.cs
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("<databaseName>");
var collection = db.GetCollection<BsonDocument>("<collectionName>");
// list your Atlas Search indexes
var result = collection.SearchIndexes.List().ToList();
foreach (var index in result)
{
Console.WriteLine(index);
}

샘플 애플리케이션을 실행하려면 csharp-list-indexes(이)라는 새 .NET 콘솔 프로젝트를 만들고 이전 코드 예시를 Program.cs 파일에 복사합니다. 그 후 다음 명령을 사용하여 프로젝트를 실행합니다.

dotnet run csharp-list-indexes.csproj
<indexes for this collection>

API 문서

이 페이지의 메서드에 대한 자세한 내용은 .NET/C# 드라이버의 API 설명서를 참조하세요.

Java 드라이버를 사용하여 컬렉션에서 Atlas Search 인덱스를 조회하려면 listSearchIndexes() 메서드를 사용하세요. Java Driver v4.11.0 이상이 있어야 합니다.

1
2

다음 샘플 애플리케이션은 지정된 컬렉션의 모든 Atlas Search 인덱스를 검색합니다.

1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoCursor;
5import com.mongodb.client.MongoDatabase;
6import org.bson.Document;
7public class ViewIndex {
8 public static void main(String[] args) {
9 // connect to your Atlas cluster
10 String uri = "<connection-string>";
11 try (MongoClient mongoClient = MongoClients.create(uri)) {
12 // set namespace
13 MongoDatabase database = mongoClient.getDatabase("<database-name>");
14 MongoCollection<Document> collection = database.getCollection("<collection-name>");
15 // retrieve indexes
16 try (MongoCursor<Document> resultsCursor = collection.listSearchIndexes().iterator()) {
17 while (resultsCursor.hasNext()) {
18 System.out.println(resultsCursor.next());
19 }
20 }
21 }
22 }
23}
3
  • <connection-string> - Atlas 연결 문자열입니다. 자세한 내용은 드라이버를 통해 연결을 참조하세요.

  • <database-name> - 컬렉션이 포함된 데이터베이스의 이름입니다.

  • <collection-name> - 인덱스를 검색하려는 컬렉션의 이름입니다.

4
javac ViewIndex.java
java ViewIndex

다음도 참조하세요.

노드 드라이버 를 통해 Atlas Search 인덱스를 검색하려면 listSearchIndexes 헬퍼 메서드를 사용합니다.

list-indexes.js라는 다음 샘플 애플리케이션을 사용하여 컬렉션의 인덱스를 반환할 수 있습니다. 다음 값을 지정합니다.

  • Atlas 연결 문자열입니다. 자세한 사항은 드라이버를 통해 연결을 참조하십시오.

  • 조회하려는 검색 인덱스가 포함된 데이터베이스와 컬렉션입니다.

  • 특정 인덱스를 검색하려는 경우 인덱스 이름입니다. 컬렉션의 모든 인덱스를 반환하려면 이 값을 생략합니다.

참고

listSearchIndexes 명령은 커서를 반환합니다. 따라서 명령과 일치하는 인덱스를 즉시 반환하지 않습니다. 결과에 액세스하려면 toArray() 메서드와 같은 커서 패러다임을 사용합니다. 자세히 알아보려면 커서에서 데이터 액세스를 참조하세요.

list-indexes.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// run the helper method
const result = await collection.listSearchIndexes("<index-name>").toArray();
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);

샘플 애플리케이션을 실행하려면 다음 명령을 사용합니다. 결과는 예제 출력과 유사해야 합니다.

node list-indexes.js
[
{
id: '648b4ad4d697b73bf9d2e5e0',
name: 'default',
status: 'READY',
queryable: true,
latestDefinition: { mappings: { dynamic: true } }
},
{
id: '648b4ad4d697b73bf9d2e5e1',
name: 'example-index',
status: 'PENDING',
queryable: false,
latestDefinition: {
mappings: { dynamic: false, fields: { text: { type: 'string' } } }
}
}
]

Python 드라이버 사용하여 Atlas Search 인덱스를 검색하려면 컬렉션에서 list_search_indexes() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션은 컬렉션에서 list_search_indexes() 메서드를 호출합니다. 이 메서드는 코드가 각 Atlas Search 인덱스에 액세스하여 출력하는 커서를 반환합니다.

from pymongo.mongo_client import MongoClient
def view_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Get a list of the collection's search indexes and print them
cursor = collection.list_search_indexes()
for index in cursor:
print(index)
3
4
python view_index.py

Atlas UI 에서 초안 으로 저장한 인덱스 정의를 재개하거나 삭제 하려면 다음을 수행합니다.

중요

보류 중인 인덱스 초안이 있는 경우 새 인덱스를 만들 수 없습니다.

1

경고

탐색 개선 진행 중

현재 새롭고 향상된 탐색 환경을 출시하고 있습니다. 다음 단계가 Atlas UI 의 보기와 일치하지 않는 경우 미리 보기 설명서를 참조하세요.

  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.

  3. 아직 표시되지 않은 경우 사이드바에서 Clusters를 클릭합니다.

    Clusters(클러스터) 페이지가 표시됩니다.

2

사이드바, Data Explorer 또는 클러스터 세부 정보 페이지에서 Atlas Search 페이지로 이동할 수 있습니다.

  1. 사이드바에서 Services 제목 아래의 Atlas Search를 클릭합니다.

    클러스터가 없는 경우 Create cluster를 클릭하여 클러스터를 생성합니다. 자세히 알아보려면 클러스터 생성을 참조하세요.

  2. 프로젝트 에 클러스터가 여러 개 있는 경우 Select cluster 드롭다운에서 사용할 클러스터 선택한 다음 Go to Atlas Search을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. cluster의 Browse Collections 버튼을 클릭합니다.

  2. 데이터베이스를 확장하고 컬렉션을 선택합니다.

  3. 컬렉션의 Search Indexes 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. 클러스터 이름을 클릭합니다.

  2. Atlas Search 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

3
4
  1. Cancel를 클릭합니다.

  2. Save Draft 또는 Delete Draft를 클릭합니다.

5
  1. 인덱스 구성을 변경하려면 Refine Your Index 을 클릭합니다.

  2. Save Changes를 클릭합니다.

6

Atlas는 인덱스가 구축 중임을 알리기 위해 토스트(간단한 비대화형 알림)를 표시합니다.

7

새로 생성된 인덱스가 Atlas Search 탭에 나타납니다. 인덱스가 빌드되는 동안 Status 필드는 Build in Progress를 읽습니다. 인덱스 빌드가 완료되면 Status 필드에 Active가 표시됩니다.

참고

컬렉션이 클수록 인덱스를 생성하는 데 시간이 더 오래 걸립니다. 인덱스 빌드가 완료되면 이메일 알림을 받게 됩니다.

기존 Atlas Search 인덱스의 인덱스 정의를 변경할 수 있습니다. 인덱스의 이름을 변경해야 하는 경우 새 인덱스를 만들고 이전 인덱스를 삭제해야 합니다.

Atlas UI 에서 또는 mongosh, Atlas CLI, API 또는 선호하는 언어 로 지원되는 MongoDB 드라이버 사용하여 프로그래밍 방식으로 Atlas Search 인덱스 편집할 수 있습니다.


언어 선택 드롭다운 메뉴를 사용하여 이 섹션에서 절차의 언어 설정하다.


API를 통해 Atlas Search 인덱스를 편집하려면 다음을 수행하세요.

1

수정하려는 Atlas Search 인덱스의 고유 ID 또는 이름을 사용하여 search/indexes/ 엔드포인트에 PATCH 요청을 보냅니다.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--include \
--request PATCH "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{indexId}" \
--data '
{
"definition":
{
"analyzer": "lucene.<analyzer>",
"analyzers": [
{
"charFilters": [ ... ],
"name": "string",
"tokenFilters": [ ... ],
"tokenizer": { ... }
}
],
"mappings": {
"dynamic": true | false,
"fields": {
"property1": {},
...
}
},
"searchAnalyzer": "<analyzer-name>",
"storedSource": {
"include | exclude": [...]
},
"synonyms": [
{
<synonym-mapping-definition>
}
}
]
}
}'

각 엔드포인트에 대한 구문과 매개변수에 대해 자세히 알아보려면 이름으로 하나씩 업데이트ID로 하나씩 업데이트를 참조하세요.

2

Atlas CLI를 사용하여 클러스터의 검색 인덱스를 업데이트하려면 다음 명령을 실행하세요.

atlas clusters search indexes update <indexId> [options]

명령 구문 및 매개변수에 대한 자세한 내용은 Atlas CLI 문서에서 Atlas 클러스터 검색 인덱스 업데이트를 참조하세요.

1

경고

탐색 개선 진행 중

현재 새롭고 향상된 탐색 환경을 출시하고 있습니다. 다음 단계가 Atlas UI 의 보기와 일치하지 않는 경우 미리 보기 설명서를 참조하세요.

  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.

  3. 아직 표시되지 않은 경우 사이드바에서 Clusters를 클릭합니다.

    Clusters(클러스터) 페이지가 표시됩니다.

2

사이드바, Data Explorer 또는 클러스터 세부 정보 페이지에서 Atlas Search 페이지로 이동할 수 있습니다.

  1. 사이드바에서 Services 제목 아래의 Atlas Search를 클릭합니다.

    클러스터가 없는 경우 Create cluster를 클릭하여 클러스터를 생성합니다. 자세히 알아보려면 클러스터 생성을 참조하세요.

  2. 프로젝트 에 클러스터가 여러 개 있는 경우 Select cluster 드롭다운에서 사용할 클러스터 선택한 다음 Go to Atlas Search을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. cluster의 Browse Collections 버튼을 클릭합니다.

  2. 데이터베이스를 확장하고 컬렉션을 선택합니다.

  3. 컬렉션의 Search Indexes 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. 클러스터 이름을 클릭합니다.

  2. Atlas Search 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

3
  • Edit With Visual Editor 안내를 따라 진행하고자 하는 경우.

  • Edit With JSON Editor 원시 인덱스 정의를 편집합니다.

4

다음 인덱스 구성 설정을 검토합니다.

비주얼 편집기 필드
설명
필요성

Index Analyzer

컬렉션 데이터 인덱싱에 사용할 분석기를 지정합니다. 기본적으로 Atlas Search는 표준 분석기(lucene.standard)를 사용합니다.

analyzer JSON 설정에 해당합니다.

옵션

Search Analyzer

텍스트를 검색하기 전에 쿼리 텍스트에 적용할 분석기를 지정합니다. 이 필드를 생략하면 인덱스는 기본적으로 다음 순서로 분석기를 상속합니다.

  1. 지정된 경우 이 필드에 대한 analyzer 옵션입니다.

  2. 지정된 경우 인덱스 에 대한 searchAnalyzer 옵션입니다.

  3. 지정된 경우 인덱스 에 대한 analyzer 옵션입니다.

  4. lucene.standard 분석기입니다.

searchAnalyzer JSON 설정에 해당합니다.

옵션

Dynamic Mapping

필드의 동적 또는 정적 매핑을 지정합니다.

기본값 으로 동적 매핑이 활성화되어 있습니다. 동적 매핑을 비활성화하려면 dynamicOff로 설정하다 . 동적 매핑을 비활성화하는 경우 인덱스 할 필드를 지정해야 합니다.

동적 및 정적 매핑에 대해 자세히 학습 필드 매핑 정의를 참조하세요.

mappings.dynamic JSON 설정에 해당합니다.

필수 사항

다음 고급 구성 설정을 검토하세요.

필드 이름
설명
필요성

Field Mappings

1}Dynamic Mapping Index Configurations 섹션의 이 비활성화된 경우 필수입니다.

인덱스 할 필드를 지정합니다.

  1. Add Field Mapping 을 클릭하여 Add Field Mapping 창을 엽니다.

  2. 필드에 대해 다음 정보를 지정합니다.

    • Field name - 인덱싱할 필드의 이름입니다.

    • Data Type - 필드 데이터 유형입니다. 지원되는 데이터 유형과 해당 옵션에 대해 자세히 알아보려면 데이터 유형 을 참조하세요.

  3. (선택 사항) 추가 속성을 지정합니다.

    추가 구성 옵션 표가 Add Field Mapping 창 에 나타납니다. 이러한 속성은 마지막 단계에서 선택한 데이터 유형 에 따라 달라집니다.

    지원되는 데이터 유형과 해당 옵션에 대해 자세히 알아보려면 데이터 유형 을 참조하세요.

  4. (선택 사항) 다중 필드 추가합니다.

    필드 인덱스 할 대체 필드 분석기 구성하려면 Add Multi Field 을 클릭합니다. 자세한 학습 은 다중 분석기를 참조하세요.

  5. 필드를 추가하려면 Add을 클릭합니다.

    Actions 열의 필드 에 대한 타원(...) 아이콘을 클릭하여 다음을 수행할 수 있습니다.

    • 구성을 수정하려면 Edit 을 클릭합니다.

    • 필드 에 대한 추가 데이터 유형을 구성하려면 Add Data Type 를 클릭합니다.

    • 인덱스 에서 필드 제거 하려면 Delete 을 클릭합니다.

필드 매핑 정의에 대해 자세히 학습 인덱스 참조를 참조하세요.

mappings.fields JSON 설정에 해당합니다.

조건부

Stored Source Fields

쿼리 시간 조회를 위해 Atlas Search에 저장 필드를 지정합니다. 지원되는 모든 데이터 유형 의 필드를 Atlas Search에 저장 수 있습니다.

필드 저장에 관한 자세한 사항은 Atlas 검색 인덱스에서 저장된 소스 필드 정의를 참조하십시오.

storedSource JSON 설정에 해당합니다.

옵션

Synonyms Mappings

인덱스 에 사용할 동의어 매핑을 지정합니다.

동의어 매핑을 사용하여 동일한 분석기 로 분석된 필드만 쿼리 할 수 있습니다.

동의어 매핑에 대해 자세히 학습 Atlas Search 인덱스에서 동의어 매핑 정의를 참조하세요.

synonyms JSON 설정에 해당합니다.

선택 사항.

Index Partitions

필드 객체가 2.1 십억을 초과하는 경우 사용할 파티션 수입니다.

numPartitions JSON 설정에 해당합니다.

선택 사항.

다음 인덱스 구성 설정을 검토합니다.

필드 이름
설명
필요성

analyzer

컬렉션 데이터 인덱싱에 사용할 분석기를 지정합니다. 기본적으로 Atlas Search는 표준 분석기(lucene.standard)를 사용합니다.

옵션

searchAnalyzer

텍스트를 검색하기 전에 쿼리 텍스트에 적용할 분석기를 지정합니다. 이 필드를 생략하면 인덱스는 기본적으로 다음 순서로 분석기를 상속합니다.

  1. 지정된 경우 이 필드에 대한 analyzer 옵션입니다.

  2. 지정된 경우 인덱스 에 대한 searchAnalyzer 옵션입니다.

  3. 지정된 경우 인덱스 에 대한 analyzer 옵션입니다.

  4. lucene.standard 분석기입니다.

옵션

mappings.dynamic

필드의 동적 또는 정적 매핑을 지정합니다. 동적 매핑을 비활성화하려면 "dynamic":false로 설정하다. 기본값 으로 동적 매핑이 활성화되어 있습니다. 동적 매핑을 비활성화하는 경우 인덱스 할 필드를 지정해야 합니다. 동적 및 정적 매핑에 대해 자세히 학습 인덱스 참조를 확인하세요.

필수 사항

다음 고급 구성 설정을 검토하세요.

필드 이름
설명
필요성

mappings.fields

mappings.dynamicfalse인 경우 필요합니다.

인덱싱할 필드를 지정합니다. 자세한 내용은 필드 매핑 정의를 참조하세요.

조건부

storedSource

쿼리 시간 조회를 위해 Atlas Search에 저장 필드를 지정합니다. 지원되는 모든 데이터 유형 의 필드를 Atlas Search에 저장 수 있습니다.

필드 저장에 관한 자세한 사항은 Atlas 검색 인덱스에서 저장된 소스 필드 정의를 참조하십시오.

옵션

synonyms

인덱스 에 사용할 동의어 매핑을 지정합니다.

동의어 매핑을 사용하여 동일한 분석기 로 분석된 필드만 쿼리 할 수 있습니다.

동의어 매핑에 대해 자세히 학습 Atlas Search 인덱스에서 동의어 매핑 정의를 참조하세요.

옵션

numPartitions

필드 객체가 2.1 십억을 초과하는 경우 사용할 파티션 수입니다.

선택 사항.

이러한 인덱스 정의 설정에 대해 자세히 학습 인덱스 참조를 확인하세요.

5

인덱스의 상태가 Active에서 Building으로 변경됩니다. 이 상태에서는 Atlas Search가 업데이트된 인덱스를 사용할 준비가 될 때까지 이전 인덱스를 삭제하지 않으므로 이전 인덱스를 계속 사용할 수 있습니다. 상태가 Active로 돌아가면 수정된 인덱스를 사용할 준비가 된 것입니다.

mongosh 을(를) 통해 Atlas Search 인덱스를 편집하려면 db.collection.updateSearchIndex() 메서드를 사용합니다.

명령의 구문은 다음과 같습니다. 편집하려는 인덱스의 이름을 지정하고 새 인덱스 정의를 정의합니다. 이 정의는 인덱스의 기존 정의를 대체합니다. 자세한 학습은 인덱스 참조를 참조하세요.

db.<collection>.updateSearchIndex(
"<index-name>",
/* updated search index definition */
)

다음 명령은 default movies 정적 매핑 을사용하도록 collection에서 검색 인덱스라는 를 업데이트합니다.

db.movies.updateSearchIndex(
"default",
{
"mappings": {
"dynamic": false,
"fields": {
"<field-name>": {
"type": "<field-type>"
}
}
}
)

참고

db.collection.updateSearchIndex() 명령은 출력을 반환하지 않습니다. Atlas UI 사용하여 인덱스 상태를볼 수 있습니다.

MongoDB Compass 사용하여 Atlas Search 인덱스 편집하려면 다음을 수행합니다.

1
2
3
4

C 드라이버를 사용하여 Atlas Search 인덱스를 편집하려면 애플리케이션에서 업데이트된 색인 정보를 지정하고 mongoc_collection_command_simple() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션은 updateSearchIndex 명령, 업데이트된 인덱스 정의 및 기존 인덱스 이름을 지정합니다. 그런 다음, 애플리케이션은 명령과 업데이트된 인덱스 정보를 BSON으로 변환하고 이 정보를 mongoc_collection_command_simple() 메서드에 전달하여 검색 인덱스를 편집합니다.

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the updated index definition
const char *cmd_str = BSON_STR({
"updateSearchIndex" : "<collectionName>",
"definition" : {"mappings" : {"dynamic" : true}},
"name" : "<indexName>"
});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Update the Atlas search index by running the command
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run updateSearchIndex: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Index updated!\n");
cleanup:
mongoc_collection_destroy (collection);
mongoc_database_destroy (database);
mongoc_client_destroy (client);
bson_destroy (&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
4
gcc -o edit-index edit-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./edit-index

C++ 드라이버를 사용하여 Atlas Search 인덱스를 편집하려면 검색 인덱스 뷰에서 update_one() 메서드를 호출합니다.

1
2

다음 샘플 애플리케이션은 검색 인덱스 뷰를 인스턴스화하고 새 Atlas Search 인덱스 정의를 지정합니다. 그런 다음 애플리케이션은 이 정의와 기존 인덱스 이름을 update_one() 메서드에 전달합니다. 이 메서드는 새 정의 문서를 반영하도록 기존 인덱스를 업데이트합니다.

#include <bsoncxx/builder/basic/document.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using namespace mongocxx;
using bsoncxx::builder::basic::make_document;
int main()
{
mongocxx::instance instance{};
try
{
// Connect to your Atlas deployment
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Access the indexes in your collection
auto siv = collection.search_indexes();
// Specify a new definiton and update your search index
auto newDefinition = make_document(kvp("mappings", make_document(kvp("dynamic", true))));
siv.update_one("<indexName>", newDefinition.view());
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
4
g++ -o edit-index edit-index.cpp $(pkg-config --cflags --libs libmongocxx)
./edit-index

.NET/C# 드라이버를 사용하여 Atlas Search 인덱스를 편집하려면 Update() 또는 UpdateAsync() 메서드를 사용합니다.

다음 샘플 애플리케이션은 기존 인덱스 정의를 업데이트합니다. 다음 값을 지정합니다.

Program.cs
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("<databaseName>");
var collection = db.GetCollection<BsonDocument>("<collectionName>");
// define your Atlas Search index
var index = new BsonDocument
{
// updated search index definition
{ "mappings", new BsonDocument
{
{ "dynamic", false },
{ "fields", new BsonDocument
{
{ "<field-name>", new BsonDocument
{
{ "type", "<field-type>" }
}
}
}
}
}
}
};
collection.SearchIndexes.Update("<index-name>", index);

샘플 애플리케이션을 실행하려면 csharp-update-index(이)라는 새 .NET 콘솔 프로젝트를 만들고 이전 코드 예시를 Program.cs 파일에 복사합니다. 그 후 다음 명령을 사용하여 프로젝트를 실행합니다.

dotnet run csharp-update-index.csproj

참고

Update() 메서드가 출력을 반환하지 않습니다. Atlas UI 사용하여 인덱스 상태를볼 수 있습니다.

API 문서

이 페이지의 메서드에 대한 자세한 내용은 .NET/C# 드라이버의 API 설명서를 참조하세요.

Java 드라이버를 사용하여 컬렉션에서 Atlas Search 인덱스를 편집하려면 검색 인덱스 설정을 수정하는 문서를 작성한 다음 updateSearchIndex() 메서드에 문서를 전달합니다. Java Driver v4.11.0 이상이 있어야 합니다.

1
2
1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import org.bson.Document;
6
7public class EditIndex {
8 public static void main(String[] args) {
9 // connect to your Atlas cluster
10 String uri = "<connection-string>";
11
12 try (MongoClient mongoClient = MongoClients.create(uri)) {
13 // set namespace
14 MongoDatabase database = mongoClient.getDatabase("<document-name>");
15 MongoCollection<Document> collection = database.getCollection("<collection-name>");
16 // define field mappings
17 Document index = new Document("analyzer", "<analyzer-name>").append(
18 "mappings", new Document("dynamic", <true|false>)
19 .append("fields", new Document("<field-name>",
20 new Document("type", "<field-type>"))));
21 // run the updateSearchIndex() method
22 collection.updateSearchIndex("<index-name>", index);
23 }
24 }
25}
3
  • <connection-string> - Atlas 연결 문자열입니다. 자세한 내용은 드라이버를 통해 연결을 참조하세요.

    참고

    연결 문자열에 writeConcern 설정을 포함하지 마세요.

  • <database-name> - 컬렉션이 포함된 데이터베이스의 이름입니다.

  • <collection-name> - 인덱스를 검색하려는 컬렉션의 이름입니다.

  • <analyzer-name> - 분석기의 이름.

  • dynamic - 필드를 자동으로 인덱싱할지 여부를 나타내는 플래그입니다.

  • <field-name> - 인덱싱할 필드의 이름입니다.

  • <field-type> - 필드 데이터 유형.

  • <index-name> - 인덱스의 이름입니다.

4
javac EditIndex.java
java EditIndex

updateSearchIndex() 메서드는 비동기적으로 실행됩니다.listSearchIndexes() 메서드를 사용하여 변경 사항이 인덱스 에 적용되었는지 확인합니다. Atlas Search 인덱스 검색에 대해 자세히 학습 Atlas Search 인덱스 보기를 참조하세요.

다음도 참조하세요.

노드 드라이버를 통해 Atlas Search 인덱스를 편집하려면 updateSearchIndex 도우미 메서드를 사용합니다.

update-index.js라는 다음 샘플 애플리케이션을 사용하여 기존 인덱스 정의를 업데이트할 수 있습니다. 다음 값을 지정합니다.

update-index.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// define your Atlas Search index
const index = {
/* updated search index definition */
"mappings": {
"dynamic": false,
"fields": {
"<field-name>": {
"type": "<field-type>"
}
}
}
}
// run the helper method
await collection.updateSearchIndex("<index-name>", index);
} finally {
await client.close();
}
}
run().catch(console.dir);

샘플 애플리케이션을 실행하려면 다음 명령을 사용합니다.

node update-index.js

참고

updateSearchIndex 메서드가 출력을 반환하지 않습니다. Atlas UI 사용하여 인덱스 상태를볼 수 있습니다.

Python Driver를 사용하여 Atlas Search 인덱스를 업데이트하려면 컬렉션에서 update_search_index() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션은 새로운 Atlas Search 인덱스 정의를 지정합니다. 그런 다음, 애플리케이션은 이 정의와 기존 인덱스 이름을 update_search_index() 메서드에 전달하고, 이 메서드는 기존 인덱스를 업데이트하여 새 정의 문서를 반영합니다.

from pymongo.mongo_client import MongoClient
def edit_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Specify a new index definition
definition = {
"mappings": {
"dynamic": True
},
}
# Update your search index
collection.update_search_index("<indexName>", definition)
3
4
python edit_index.py

참고

업데이트된 인덱스 작성되는 동안 여러 노드가 다양한 속도로 업데이트 될 수 있습니다. 이 기간 동안 새 인덱스 정의와 이전 인덱스 정의를 모두 반영하는 혼합 쿼리 결과가 발생할 수 있습니다. 인덱스 상태 세부 정보 페이지에서 쿼리를 제공하는 인덱스 볼 수 있습니다.

일부 Atlas Search 기능을 사용하려면 인덱스를 업데이트해야 합니다. 인덱스를 업데이트하려면 다음 조치 중 하나를 수행하면 됩니다.

  • Atlas Search인덱스 편집의 단계에 따라 인덱스 정의를 편집합니다.

  • Atlas UI 에서 인덱스 업데이트 선택하려면 다음 단계를 수행하세요.

중요

Atlas Search 인덱스를 업데이트하는 프로세스에는 시간과 리소스가 필요합니다. 인덱스 업데이트가 성공적으로 완료되려면 현재 인덱스 디스크 공간의 125%에 해당하는 여유 디스크 공간을 할당하세요.

1

경고

탐색 개선 진행 중

현재 새롭고 향상된 탐색 환경을 출시하고 있습니다. 다음 단계가 Atlas UI 의 보기와 일치하지 않는 경우 미리 보기 설명서를 참조하세요.

  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.

  3. 아직 표시되지 않은 경우 사이드바에서 Clusters를 클릭합니다.

    Clusters(클러스터) 페이지가 표시됩니다.

2

사이드바, Data Explorer 또는 클러스터 세부 정보 페이지에서 Atlas Search 페이지로 이동할 수 있습니다.

  1. 사이드바에서 Services 제목 아래의 Atlas Search를 클릭합니다.

    클러스터가 없는 경우 Create cluster를 클릭하여 클러스터를 생성합니다. 자세히 알아보려면 클러스터 생성을 참조하세요.

  2. 프로젝트 에 클러스터가 여러 개 있는 경우 Select cluster 드롭다운에서 사용할 클러스터 선택한 다음 Go to Atlas Search을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. cluster의 Browse Collections 버튼을 클릭합니다.

  2. 데이터베이스를 확장하고 컬렉션을 선택합니다.

  3. 컬렉션의 Search Indexes 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. 클러스터 이름을 클릭합니다.

  2. Atlas Search 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

3

새 기능을 사용하기 위해 인덱스를 업데이트해야 하는 경우 Atlas UI의 인덱스 이름 옆에 경고 아이콘이 표시됩니다.

4
  1. Index Overview 페이지에서 배너의 Update를 클릭합니다.

  2. 확인 창에서 Update Index을(를) 클릭합니다.

    인덱스가 업데이트되는 동안 이전 인덱스를 사용하여 컬렉션을 계속 쿼리할 수 있습니다.

Atlas UI 에서 또는 mongosh, Atlas CLI, API 또는 선호하는 언어 로 지원되는 MongoDB 드라이버 사용하여 프로그래밍 방식으로 Atlas Search 인덱스 삭제 수 있습니다.


언어 선택 드롭다운 메뉴를 사용하여 이 섹션에서 절차의 언어 설정하다.


API를 통해 Atlas Search 인덱스를 삭제하려면 다음을 수행하세요.

1

삭제하려는 Atlas Search 인덱스의 고유 ID 또는 이름을 포함하여 search/indexes/ 엔드포인트로 DELETE 요청을 전송합니다.

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request DELETE "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{indexId}"

두 엔드포인트의 구문 및 매개변수에 대해 자세히 알아보려면 이름으로 1개 삭제 및 ID로 1개 삭제를 참조하세요.

2

Atlas CLI를 사용하여 cluster에서 검색 인덱스를 삭제하려면 다음 명령을 실행하세요.

atlas clusters search indexes delete <indexId> [options]

명령 구문 및 매개변수에 대한 자세한 내용은 Atlas CLI 문서에서 Atlas 클러스터 검색 인덱스 삭제를 참조하세요.

Atlas CLI를 사용하여 지정된 배포에 대해 지정된 검색 인덱스를 삭제하려면 다음 명령을 실행합니다.

atlas deployments search indexes delete <indexId> [options]

명령 구문 및 매개변수에 대해 자세히 알아보려면 Atlas 배포에 대한 Atlas CLI 설명서에서 Atlas Search 인덱스 삭제를 참조하세요.

1

경고

탐색 개선 진행 중

현재 새롭고 향상된 탐색 환경을 출시하고 있습니다. 다음 단계가 Atlas UI 의 보기와 일치하지 않는 경우 미리 보기 설명서를 참조하세요.

  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 원하는 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 탐색 표시줄의 Projects 메뉴에서 원하는 프로젝트를 선택합니다.

  3. 아직 표시되지 않은 경우 사이드바에서 Clusters를 클릭합니다.

    Clusters(클러스터) 페이지가 표시됩니다.

2

사이드바, Data Explorer 또는 클러스터 세부 정보 페이지에서 Atlas Search 페이지로 이동할 수 있습니다.

  1. 사이드바에서 Services 제목 아래의 Atlas Search를 클릭합니다.

    클러스터가 없는 경우 Create cluster를 클릭하여 클러스터를 생성합니다. 자세히 알아보려면 클러스터 생성을 참조하세요.

  2. 프로젝트 에 클러스터가 여러 개 있는 경우 Select cluster 드롭다운에서 사용할 클러스터 선택한 다음 Go to Atlas Search을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. cluster의 Browse Collections 버튼을 클릭합니다.

  2. 데이터베이스를 확장하고 컬렉션을 선택합니다.

  3. 컬렉션의 Search Indexes 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

  1. 클러스터 이름을 클릭합니다.

  2. Atlas Search 탭을 클릭합니다.

    Atlas Search 페이지가 표시됩니다.

3

ellipsis 버튼은 패널 오른쪽에 있습니다. 원하는 인덱스 옆의 버튼을 클릭하고 Delete Index 을 선택합니다.

4

mongosh를 통해 Atlas Search 인덱스를 삭제하려면 db.collection.dropSearchIndex() 메서드를 사용합니다.

명령은 다음과 같은 구문을 가집니다:

db.<collection>.dropSearchIndex("<index-name>")

다음 명령은 movies 컬렉션의 default 검색 인덱스를 삭제합니다.

db.movies.dropSearchIndex("default")

참고

db.collection.dropSearchIndex() 명령은 출력을 반환하지 않습니다. Atlas UI 사용하여 인덱스 상태를볼 수 있습니다.

MongoDB Compass 사용하여 Atlas Search 인덱스 삭제 하려면 다음을 수행합니다.

1
2
3
4

C 드라이버를 사용하여 Atlas Search 인덱스를 삭제하려면 컬렉션과 제거 명령을 mongoc_collection_command_simple() 메서드에 전달합니다.

1
2

다음 샘플 애플리케이션은 dropSearchIndex 명령과 기존 인덱스 이름을 지정합니다. 이후 애플리케이션은 명령과 인덱스 정보를 BSON으로 변환하고, 이 정보를 mongoc_collection_command_simple() 메서드에 전달하여 검색 인덱스를 삭제합니다.

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the index name
const char *cmd_str =
BSON_STR ({"dropSearchIndex" : "<collectionName>", "name" : "<indexName>"});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Run the command to drop the search index
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run dropSearchIndex: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Index dropped!\n");
cleanup:
mongoc_collection_destroy(collection);
mongoc_database_destroy(database);
mongoc_client_destroy(client);
bson_destroy(&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
4
gcc -o delete-index delete-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./delete-index

C++ 드라이버를 사용하여 Atlas Search 인덱스를 삭제하려면 검색 인덱스 뷰에서 drop_one() 메서드를 호출합니다.

1
2

다음 샘플 애플리케이션은 대상 컬렉션에 search_indexes() 메서드를 사용하여 검색 인덱스 보기를 인스턴스화합니다. 그런 다음 애플리케이션은 보기에서 drop_one() 메서드를 호출하고 Atlas Search 인덱스 이름을 파라미터로 전달하여 인덱스를 삭제합니다.

#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using namespace mongocxx;
int main()
{
mongocxx::instance instance{};
try
{
// Connect to your Atlas deployment
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Access the indexes in your collection
auto siv = collection.search_indexes();
// Delete your search index
auto name = "<indexName>";
siv.drop_one(name);
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
4
g++ -o delete-index delete-index.cpp $(pkg-config --cflags --libs libmongocxx)
./delete-index

.NET/C# 드라이버를 사용하여 Atlas Search 인덱스를 삭제하려면 DropOne() 또는 DropOneAsync() 메서드를 사용합니다.

다음 샘플 애플리케이션은 컬렉션에서 인덱스를 삭제합니다. 다음 값을 지정합니다.

Program.cs
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("<databaseName>");
var collection = db.GetCollection<BsonDocument>("<collectionName>");
// drop your Atlas Search index
collection.SearchIndexes.DropOne("<index name>");

샘플 애플리케이션을 실행하려면 csharp-delete-index(이)라는 새 .NET 콘솔 프로젝트를 만들고 이전 코드 예시를 Program.cs 파일에 복사합니다. 그 후 다음 명령을 사용하여 프로젝트를 실행합니다.

dotnet run csharp-delete-index.csproj

참고

DropOne() 메서드가 출력을 반환하지 않습니다. Atlas UI 사용하여 인덱스 상태를볼 수 있습니다.

API 문서

이 페이지의 메서드에 대한 자세한 내용은 .NET/C# 드라이버의 API 설명서를 참조하세요.

Java Driver를 사용하여 컬렉션에서 Atlas Search 인덱스를 삭제하려면 dropSearchIndex() 메서드를 사용합니다. Java Driver v4.11.0 이상이 있어야 합니다.

1
2

다음 샘플 애플리케이션은 지정된 컬렉션에서 지정된 Atlas Search 인덱스를 삭제합니다.

1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import org.bson.Document;
6
7public class DeleteIndex {
8 public static void main(String[] args) {
9 // connect to your Atlas cluster
10 String uri = "<connection-string>";
11
12 try (MongoClient mongoClient = MongoClients.create(uri)) {
13 // set namespace
14 MongoDatabase database = mongoClient.getDatabase("<database-name>");
15 MongoCollection<Document> collection = database.getCollection("<collection>");
16 // delete the index
17 collection.dropSearchIndex("<index-name>");
18 }
19 }
20}
3
  • <connection-string> - Atlas 연결 문자열입니다. 자세한 내용은 드라이버를 통해 연결을 참조하세요.

    참고

    연결 문자열에 writeConcern 설정을 포함하지 마세요.

  • <database-name> - 컬렉션이 포함된 데이터베이스의 이름입니다.

  • <collection-name> - 인덱스를 검색하려는 컬렉션의 이름입니다.

  • <index-name> - 삭제할 인덱스의 이름입니다.

4
javac DeleteIndex.java
java DeleteIndex

다음도 참조하세요.

노드 드라이버 를 통해 Atlas Search 인덱스를 삭제하려면 dropSearchIndex 헬퍼 메서드를 사용합니다.

drop-index.js 이)라는 이름의 다음 샘플 애플리케이션을 사용하여 collection에서 인덱스를 삭제할 수 있습니다. 다음 값을 지정합니다.

drop-index.js
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// run the helper method
await collection.dropSearchIndex("<index-name>");
} finally {
await client.close();
}
}
run().catch(console.dir);

샘플 애플리케이션을 실행하려면 다음 명령을 사용합니다.

node drop-index.js

참고

dropSearchIndex 메서드가 출력을 반환하지 않습니다. Atlas UI 사용하여 인덱스 상태를볼 수 있습니다.

Python Driver를 사용하여 Atlas Search 인덱스를 삭제하려면 컬렉션에서 drop_search_index() 메서드를 호출하세요.

1
2

다음 샘플 애플리케이션은 Atlas Search 인덱스 이름을 drop_search_index() 메서드에 전달하여 인덱스를 삭제합니다.

from pymongo.mongo_client import MongoClient
def delete_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Delete your search index
collection.drop_search_index("<indexName>")
3
4
python delete_index.py

mongot 프로세스 인덱싱된 필드와 _id 필드 디스크에 저장하므로 인덱스를 빌드 전에 인덱스 의 크기를 조정하는 것이 좋습니다. 컬렉션 의 하위 집합에 인덱스 만들고 다음 공식을 사용하여 데이터의 총 크기를 기준으로 샘플 데이터 인덱스 의 크기를 확장 전체 Atlas Search 인덱스 의 크기를 추정할 수 있습니다.

estimated-index-size = ( subset-data-index-size / subset-data-size ) x total-collection-data-size

예시 들어 movies 데이터베이스 의 컬렉션 에 대한 인덱스 크기를 추정하려면 sample_mflix 에서 다음 단계를 mongosh 수행합니다.

  1. $sample 를 실행하여 데이터의 무작위 샘플 사용하여 sample_data 라는 새 컬렉션 만듭니다.

    use sample_mflix
    db.movies.aggregate([
    { $sample: { size: 10 } },
    { $out: "sample_data" }
    ])
    [
    {
    _id: ObjectId('573a13bbf29313caabd53f9c'),
    plot: "Three years ago, in real-life, Hama Ali, a charismatic actor from Iraq famous locally for his performance as Iraq's version of Superman, met Ayca on a film-set. He and Ayca, a fiery actress...",
    genres: [ 'Drama', 'Romance', 'War' ],
    runtime: 93,
    cast: [
    'Ayèa Damgaci',
    'Hama Ali Kahn',
    'Cengiz Bozkurt',
    'Nesrin Cavadzade'
    ],
    num_mflix_comments: 1,
    poster: 'https://m.media-amazon.com/images/M/MV5BMjA1OTI1MjI4OV5BMl5BanBnXkFtZTgwODk1MTA2MDE@._V1_SY1000_SX677_AL_.jpg',
    title: 'Gitmek: My Marlon and Brando',
    fullplot: "Three years ago, in real-life, Hama Ali, a charismatic actor from Iraq famous locally for his performance as Iraq's version of Superman, met Ayca on a film-set. He and Ayca, a fiery actress from Turkey, had a passionate love affair before returning to their respective homes. From his Kurdish village, Hama Ali sends Ayca video love letters which he has filmed on his handycam. She watches them from her sofa in Istanbul, with her cat for company. The video love letters capture the hellish violence engulfing Iraq, the goats and uncles populating his rural area, and also his tender affection towards her. Feeling suffocated by her own city and angered by the indifference towards the war that surrounds her, Ayca decides to make the journey eastwards to Iraq to be reunited with her lover. GITMEK, a dramatic feature film, is based on the true story of Ayca's departure from Istanbul and her extraordinary journey to the Iraqi border. At a time when many people were fleeing from East to West in search of safety, Ayca makes the opposite journey, in search of love. She is helped by immigrant artists who live in the slums of Istanbul and the mothers of long distance truck drivers who she meets at various border towns. The journey takes her through breathtaking landscapes, strange encounters and terrifying times.",
    languages: [ 'English', 'Kurdish', 'Turkish' ],
    released: ISODate('2008-11-14T00:00:00.000Z'),
    directors: [ 'Huseyin Karabey' ],
    writers: [ 'Ayèa Damgaci', 'Huseyin Karabey' ],
    awards: { wins: 12, nominations: 4, text: '12 wins & 4 nominations.' },
    lastupdated: '2015-07-04 00:20:59.083000000',
    year: 2008,
    imdb: { rating: 6.6, votes: 628, id: 920460 },
    countries: [ 'Turkey' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.7, numReviews: 181, meter: 79 },
    lastUpdated: ISODate('2015-07-16T18:10:38.000Z')
    }
    },
    {
    _id: ObjectId('573a139af29313caabcefb6a'),
    plot: '48 hours of intersecting lives and crimes in Los Angeles.',
    genres: [ 'Comedy', 'Crime', 'Drama' ],
    runtime: 104,
    rated: 'R',
    cast: [
    'Danny Aiello',
    'Greg Cruttwell',
    'Jeff Daniels',
    'Teri Hatcher'
    ],
    num_mflix_comments: 1,
    poster: 'https://m.media-amazon.com/images/M/MV5BZDI0ZmFmYTgtMTQ5OS00MTVmLTgwNWYtNzIyY2Y5NjYxNzgyXkEyXkFqcGdeQXVyNzc5MjA3OA@@._V1_SY1000_SX677_AL_.jpg',
    title: '2 Days in the Valley',
    fullplot: 'John Herzfeld deftly welds together a multitude of subplots-- a loser hitman and a cool assassin involved in an insurance scam; a washed-up director, turned suicidal, if only he had someone to care for his beloved dog; a snooty art dealer, wracked by kidney stones, cared for by his devoted assistant; a grungy deranged vice cop, now partnered with a fresh-faced rookie; and two beautiful and jealous women entangled in their deadly scheme--into a spoof of the crime thriller genre.',
    languages: [ 'English', 'Vietnamese' ],
    released: ISODate('1996-09-27T00:00:00.000Z'),
    directors: [ 'John Herzfeld' ],
    writers: [ 'John Herzfeld' ],
    awards: { wins: 0, nominations: 1, text: '1 nomination.' },
    lastupdated: '2015-09-11 00:42:22.520000000',
    year: 1996,
    imdb: { rating: 6.5, votes: 15019, id: 115438 },
    countries: [ 'USA' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3, numReviews: 14630, meter: 55 },
    dvd: ISODate('2001-08-07T00:00:00.000Z'),
    critic: { rating: 6, numReviews: 53, meter: 60 },
    lastUpdated: ISODate('2015-08-19T18:25:36.000Z'),
    consensus: 'A labyrinthine thriller with a host of memorable characters, 2 Days in the Valley is an uneven but intriguing thriller/black comedy.',
    rotten: 21,
    production: 'HBO Video',
    fresh: 32
    }
    },
    {
    _id: ObjectId('573a13bdf29313caabd5943e'),
    fullplot: "When Emily Parris exposes a secret society of teenage girls who have slipped out of the world of social media and into another world they've discovered in the woods at night. When she accuses the girls of committing sexually deviant activities, Emily sends the small American town into a atmosphere of hysteria and the national media spotlight. The mystery deepens when each of the accused girls upholds a vow of silence.",
    imdb: { rating: 6.2, votes: 861, id: 1015471 },
    year: 2014,
    plot: "When a teenage girl says she's the victim of a secret network called The Sisterhood of Night, a quiet suburban town becomes the backdrop for a modern-day Salem witch trial.",
    genres: [ 'Drama', 'Mystery', 'Thriller' ],
    rated: 'PG-13',
    metacritic: 60,
    title: 'The Sisterhood of Night',
    lastupdated: '2015-09-10 17:22:16.113000000',
    languages: [ 'English' ],
    writers: [ 'Marilyn Fu (screenplay)', 'Steven Millhauser (short story)' ],
    type: 'movie',
    tomatoes: {
    website: 'http://www.thesisterhoodofnight-movie.com/',
    viewer: { rating: 3.6, numReviews: 382, meter: 65 },
    dvd: ISODate('2015-06-09T00:00:00.000Z'),
    critic: { rating: 6.6, numReviews: 19, meter: 79 },
    boxOffice: '$5.3k',
    rotten: 4,
    production: 'Cine Mosaic',
    lastUpdated: ISODate('2015-09-13T17:24:37.000Z'),
    fresh: 15
    },
    poster: 'https://m.media-amazon.com/images/M/MV5BODg3MjE0MDM4N15BMl5BanBnXkFtZTgwOTY0MjE5NDE@._V1_SY1000_SX677_AL_.jpg',
    num_mflix_comments: 1,
    released: ISODate('2014-10-18T00:00:00.000Z'),
    awards: { wins: 2, nominations: 3, text: '2 wins & 3 nominations.' },
    countries: [ 'USA' ],
    cast: [
    'Georgie Henley',
    'Kara Hayward',
    'Willa Cuthrell',
    'Olivia DeJonge'
    ],
    directors: [ 'Caryn Waechter' ],
    runtime: 104
    },
    {
    _id: ObjectId('573a13c4f29313caabd6d7bf'),
    plot: 'A film producer struggles with suicidal despair.',
    genres: [ 'Drama' ],
    runtime: 110,
    metacritic: 76,
    cast: [
    'Louis-Do de Lencquesaing',
    'Chiara Caselli',
    'Alice de Lencquesaing',
    'Alice Gautier'
    ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMTUxODczODA2NV5BMl5BanBnXkFtZTcwNzExMjQ1Mw@@._V1_SY1000_SX677_AL_.jpg',
    title: 'Father of My Children',
    fullplot: "In the first half, Gregoire, a movie producer of great charm, owner of Moon Films, plays with his younger daughters, talks with his wife and his eldest daughter, and keeps his studio going while one project hemorrhages money and creditors circle. In the second half, Sylvia, his Italian wife, tries to hold the family together as she looks fully into Moon Films' troubles. She meets with a banker, a temperamental Swede, Russian TV magnates, a film lab exec, and Moon's lawyer. Clèmence, the oldest daughter, goes on her own search. Debt can crush; how does a family pick up the pieces?",
    languages: [ 'French' ],
    released: ISODate('2009-12-16T00:00:00.000Z'),
    directors: [ 'Mia Hansen-Lève' ],
    writers: [ 'Mia Hansen-Lève (screenplay)' ],
    awards: { wins: 2, nominations: 3, text: '2 wins & 3 nominations.' },
    lastupdated: '2015-09-02 00:01:22.897000000',
    year: 2009,
    imdb: { rating: 6.7, votes: 1820, id: 1356928 },
    countries: [ 'France', 'Germany', 'Belgium' ],
    type: 'movie',
    tomatoes: {
    website: 'http://www.filmsdulosange.fr/fr/fr_peredemesenfants.html',
    viewer: { rating: 3.3, numReviews: 1232, meter: 60 },
    dvd: ISODate('2010-06-21T00:00:00.000Z'),
    critic: { rating: 7.4, numReviews: 55, meter: 91 },
    lastUpdated: ISODate('2015-09-11T18:38:12.000Z'),
    consensus: 'A tragedy gracefully lifted by tender empathy and moments of joy, Father of My Children is a quiet triumph for writer-director Mia Hansen-Love.',
    rotten: 5,
    production: 'IFC Films',
    fresh: 50
    }
    },
    {
    _id: ObjectId('573a13a5f29313caabd15cc1'),
    plot: 'After a 13-year imprisonment in Hong Kong, a kickboxer challenges the current champion in order to restore his honor.',
    genres: [ 'Drama', 'Romance', 'Sport' ],
    runtime: 105,
    cast: [
    'Andy Lau',
    'Takako Tokiwa',
    'Inthira Charoenpura',
    'Apichaya Thanatthanapong'
    ],
    title: 'Ah Fu',
    lastupdated: '2015-09-14 12:56:13.823000000',
    languages: [ 'Cantonese' ],
    released: ISODate('2000-11-21T00:00:00.000Z'),
    directors: [ 'Daniel Lee' ],
    writers: [ 'Chi-Sing Cheung', 'Daniel Lee' ],
    awards: { wins: 1, nominations: 3, text: '1 win & 3 nominations.' },
    year: 2000,
    imdb: { rating: 6.6, votes: 350, id: 277558 },
    countries: [ 'Hong Kong' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.3, numReviews: 644, meter: 57 },
    lastUpdated: ISODate('2015-04-25T18:41:33.000Z')
    },
    num_mflix_comments: 0
    },
    {
    _id: ObjectId('573a13bef29313caabd5ce2b'),
    plot: 'Johann Sebastian Bach llega con su familia a Leipzig para ocupar el puesto de cantor en la Escuela de Santo Tomès...',
    genres: [ 'Musical' ],
    runtime: 102,
    metacritic: 70,
    cast: [
    'Christian Atanasiu',
    'Fèodor Atkine',
    'George-Christoph Biller',
    'Christian Brembeck'
    ],
    title: 'The Silence Before Bach',
    lastupdated: '2015-05-25 00:50:52.210000000',
    languages: [ 'Spanish', 'German', 'Catalan' ],
    released: ISODate('2007-12-21T00:00:00.000Z'),
    directors: [ 'Pere Portabella' ],
    writers: [ 'Xavier Albertè', 'Pere Portabella', 'Carles Santos' ],
    awards: { wins: 3, nominations: 3, text: '3 wins & 3 nominations.' },
    year: 2007,
    imdb: { rating: 6.8, votes: 329, id: 1079450 },
    countries: [ 'Spain' ],
    type: 'movie',
    tomatoes: {
    website: 'http://www.pereportabella.com/eng/fla/die/home_eng.html',
    viewer: { rating: 3.5, numReviews: 391, meter: 64 },
    critic: { rating: 6.6, numReviews: 16, meter: 81 },
    lastUpdated: ISODate('2015-08-11T19:15:49.000Z'),
    rotten: 3,
    production: 'Film Forum',
    fresh: 13
    },
    num_mflix_comments: 0
    },
    {
    _id: ObjectId('573a13ccf29313caabd83260'),
    plot: 'A woman subject to mental, physical, and sexual abuse on a remote island seeks a way out.',
    genres: [ 'Crime', 'Drama', 'Horror' ],
    runtime: 115,
    cast: [ 'Yeong-hie Seo', 'Seong-won Ji', 'Min-ho Hwang', 'Min Je' ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMjAyNDEwMDgzMl5BMl5BanBnXkFtZTcwNzMyMTYwNQ@@._V1_SY1000_SX677_AL_.jpg',
    title: 'Bedevilled',
    fullplot: "Hae-won is a beautiful single woman in her thirties who works at a bank in the Seoul city. She leads a busy life until she becomes a witness to an attempted murder case, and at the same time, things get complicated at work. When things get out of hand she is forced to take a vacation so she heads for 'Moodo', a small undeveloped island, where she had once visited to see her grandparents. And where she had befriended a girl named Bok-nam who stills writes to Hae-won asking her to visit despite the fact that Hae-won never bothered to reply. Upon arriving at the island, Hae-won is shocked to see everyone treating Bok-nam like a slave. As practically the only young woman on the island, she is a plaything for all the men and a free laborer for the women. Sick of all the inhumane treatment, Bok-nam had tried to escape the island several times in the past but had failed each time. She begs Hae-won to help her escape the place, but Hae-won remains indifferent not wanting to be involved in complicated situations. When Bok-nam realizes that her own daughter will follow her footsteps, she tries to escape the island with her daughter.",
    languages: [ 'Korean' ],
    released: ISODate('2010-09-02T00:00:00.000Z'),
    directors: [ 'Cheol-soo Jang' ],
    writers: [ 'Kwang-young Choi' ],
    awards: { wins: 10, nominations: 5, text: '10 wins & 5 nominations.' },
    lastupdated: '2015-09-01 01:18:02.960000000',
    year: 2010,
    imdb: { rating: 7.3, votes: 7983, id: 1646959 },
    countries: [ 'South Korea' ],
    type: 'movie'
    },
    {
    _id: ObjectId('573a13c7f29313caabd746fe'),
    plot: 'A Californian family inherits a castle in Romania. This is especially exciting to the son, who is obsessed with monsters. And he is not disappointed.',
    genres: [ 'Comedy', 'Family' ],
    runtime: 83,
    rated: 'TV-G',
    cast: [
    'Victoria Justice',
    'Chase Ellison',
    'Anna Galvin',
    'Matt Winston'
    ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMjU1MmJlMTctY2FiMC00MmU1LWI5NmYtMDc5OWM0NjEzMmI2XkEyXkFqcGdeQXVyNDgyODgxNjE@._V1_SY1000_SX677_AL_.jpg',
    title: 'The Boy Who Cried Werewolf',
    fullplot: 'A Californian family inherits a castle in Romania. This is especially exciting to the son, who is obsessed with monsters. And he is not disappointed.',
    languages: [ 'English' ],
    released: ISODate('2010-10-22T00:00:00.000Z'),
    directors: [ 'Eric Bross' ],
    writers: [ 'Art Edler Brown', 'Douglas Sloan' ],
    awards: { wins: 1, nominations: 2, text: '1 win & 2 nominations.' },
    lastupdated: '2015-08-20 00:01:59.673000000',
    year: 2010,
    imdb: { rating: 6.3, votes: 1582, id: 1451423 },
    countries: [ 'USA', 'Canada' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.7, numReviews: 762, meter: 66 },
    lastUpdated: ISODate('2015-09-12T17:30:20.000Z')
    }
    },
    {
    _id: ObjectId('573a13b4f29313caabd3f473'),
    genres: [ 'Documentary' ],
    runtime: 85,
    title: 'Zero Degrees of Separation',
    countries: [ 'Canada' ],
    lastupdated: '2015-08-09 00:30:38.977000000',
    languages: [ 'Arabic', 'English', 'Hebrew' ],
    released: ISODate('2005-06-22T00:00:00.000Z'),
    directors: [ 'Elle Flanders' ],
    writers: [ 'Elle Flanders' ],
    awards: { wins: 1, nominations: 0, text: '1 win.' },
    year: 2005,
    imdb: { rating: 6.6, votes: 90, id: 454990 },
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.5, numReviews: 5, meter: 100 },
    fresh: 1,
    critic: { numReviews: 2 },
    rotten: 1,
    lastUpdated: ISODate('2015-01-04T23:25:58.000Z')
    },
    num_mflix_comments: 0
    },
    {
    _id: ObjectId('573a13bff29313caabd5f070'),
    plot: 'This hilarious genre-bending comedy follows Gary Brewer, along with girlfriend Holly Brewer (no relation), and best friend Trevor Morehouse as Gary quests to reign supreme at the 2006 Rock, Paper, Scissors World Championships.',
    genres: [ 'Comedy' ],
    runtime: 85,
    cast: [ 'Tim Doiron', 'April Mullen', 'Ryan Tilley', 'Peter Pasyk' ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMTI5MzIwMjA2Ml5BMl5BanBnXkFtZTcwOTcyOTA4MQ@@._V1_SY1000_SX677_AL_.jpg',
    title: 'Rock, Paper, Scissors: The Way of the Tosser',
    fullplot: 'This hilarious genre-bending comedy follows Gary Brewer, along with girlfriend Holly Brewer (no relation), and best friend Trevor Morehouse as Gary quests to reign supreme at the 2006 Rock, Paper, Scissors World Championships.',
    languages: [ 'English' ],
    released: ISODate('2007-07-06T00:00:00.000Z'),
    directors: [ 'Tim Doiron', 'April Mullen' ],
    writers: [ 'Tim Doiron (creator)', 'April Mullen (creator)', 'Tim Doiron' ],
    awards: { wins: 2, nominations: 0, text: '2 wins.' },
    lastupdated: '2015-08-12 00:01:33.813000000',
    year: 2007,
    imdb: { rating: 6.2, votes: 316, id: 1121964 },
    countries: [ 'Canada' ],
    type: 'movie'
    }
    ]
  2. 전체 컬렉션 에 사용할 인덱스 정의를 사용하여 샘플 데이터로 컬렉션 에 검색 인덱스 만듭니다.

    db.sample_data.createSearchIndex(
    "sample-index",
    { mappings: { dynamic: true } }
    )
    sample-index
  3. 컬렉션 의 총 크기에 따라 샘플 데이터의 크기를 조정합니다. 예시 를 들어 Atlas UI 인덱스 개요 페이지에 따르면 sample-index 인덱스 의 크기가 44.88인 경우 다음 명령을 사용하여 총 인덱스 크기를 계산할 수 있습니다.

    let sampleSize = db.sample_data.totalSize()
    let totalSize = db.movies.totalSize()
    let totalIndexSize = ( 44.88 / sampleSize ) * totalSize; totalIndexSize
    45864.28

Atlas UI 에서 Atlas Search 페이지의 Status 열에는 클러스터 의 프라이머리 노드 에 있는 인덱스 의 현재 상태가 표시됩니다. 다음 표에서는 가능한 인덱스 상태에 대해 설명합니다.

상태
설명

보류 중

Atlas가 아직 인덱스 빌드를 시작하지 않았습니다.

건물

Atlas가 인덱스를 작성하거나 편집 후 인덱스를 다시 작성하고 있습니다. 인덱스가 이 상태인 경우 다음과 같습니다:

  • 새 인덱스의 경우 Atlas Search는 인덱스 빌드가 완료될 때까지 쿼리를 제공하지 않습니다.

  • 기존 인덱스의 경우 인덱스가 다시 빌드될 때까지 기존 쿼리와 새 쿼리에 대해 이전 인덱스를 계속 사용할 수 있습니다.

준비 완료

인덱스를 사용할 준비가 되었습니다.

Stale

다음과 같은 이유로 인해 인덱스가 오래되었습니다.

  • 디스크 사용률이 높아 복제가 중지되었습니다.

    복제 일시 중지 임계값은 90%이고 복제 재개 임계값은 85% 디스크 사용률입니다.

  • 복제가 장기간 중지되면 Atlas Search mongot 프로세스가 oplog에서 제외됩니다.

    이 상태는 일반적으로 mongod oplog에서 현재 복제 지점을 더 이상 사용할 수 없을 때 발생합니다. mongot 프로세스가 oplog에서 중단되면 Atlas는 인덱스를 다시 작성합니다.

  • 인덱스가 20억 개의 문서 제한에 도달했습니다.

  • 오류로 인해 복제가 실패했습니다.

기존 인덱스는 계속 쿼리할 수 있습니다. 그러나 오래된 인덱스에 대한 쿼리 결과에는 오래된 데이터가 포함될 수 있습니다. 검색 노드를 확장하여 디스크 공간을 늘리고 기존 인덱스를 삭제하여 디스크 공간을 확보할 수 있습니다. 또는 View status details 모달 창의 오류를 사용하여 문제를 해결하세요. 자세한 내용은 Atlas Search 문제 해결을 참조하세요.

실패하였습니다.

Atlas에서 인덱스를 작성할 수 없습니다. View status details 모달 창의 오류를 사용하여 문제를 해결하세요. 자세한 내용은 Atlas Search 문제 해결을 참조하세요.

삭제

Atlas가 클러스터 노드에서 인덱스를 삭제하는 중입니다.

존재하지 않음

인덱스가 유효하지 않은 이유는 인덱스에 대한 컬렉션이 더 이상 존재하지 않기 때문입니다. 해당 인덱스에 대한 컬렉션이 없으므로 이 인덱스에 대한 쿼리를 실행할 수 없습니다. Atlas는 결국 해당 인덱스를 삭제합니다.

다음 방법 중 하나를 사용하여 Status Details 페이지에서 자세한 상태 정보를 볼 수 있습니다.

  • Status 열에서 View status details 링크를 클릭합니다.

  • Index Name 열에서 이름을 클릭한 다음 Index Overview 왼쪽에 있는 메뉴에서 Status Details 를 선택합니다.

Status Details 페이지에는 다음 섹션이 포함되어 있습니다.

이 섹션에는 쿼리를 제공 데 사용되는 인덱스 표시됩니다.

컬렉션에 대해 해당하는 이름을 가진 인덱스 버전이 하나뿐인 경우, 섹션에는 사용 중인 인덱스에 대한 인덱스 정의를 볼 수 있는 Index Overview 링크가 포함됩니다.

컬렉션에 이름이 동일하지만 다른 인덱스가 있는 경우, 이 섹션에는 최신 인덱스 정의가 표시되며 다른 탭에서 복사할 수 있는 이전 유효한 버전의 인덱스도 표시됩니다.

인덱스를 업데이트할 때 서로 다른 노드는 서로 다른 속도로 업데이트를 적용합니다. 따라서 일부 노드는 최신 버전을 사용할 수 있고, 일부는 이전 버전을 사용할 수 있습니다. Atlas는 변경 사항이 모든 노드에 적용될 때까지 두 버전의 인덱스를 모두 표시합니다.

잘못된 인덱스 정의로 인덱스를 업데이트하려고 하면 인덱스 빌드가 실패하고 Atlas는 이전의 유효한 인덱스 정의만 표시합니다.

이 섹션은 클러스터의 각 노드에 대한 인덱스 상태를 표시합니다. 각 노드의 인덱스에 대한 자세한 내용은 다음과 같습니다.

Shard

샤드 이름.

Node

노드 정보.

Status

샤드 내 노드에 있는 인덱스의 상태입니다.

Queryable

인덱스가 쿼리를 처리할 수 있는지 여부를 나타내는 아이콘.

Message

인덱스 상태의 이유입니다. Stale 또는 Failed 상태의 인덱스에 대해 인덱스가 부실한 이유 또는 인덱스 빌드가 실패한 이유를 표시합니다.

Node Type

노드 유형입니다. 값은 다음 유형 중 하나일 수 있습니다.

  • 기본

  • 보조

  • 검색 노드

Region

노드 리전

Size

노드에 있는 인덱스의 크기입니다.

Documents

인덱스된 문서의 개수 및 백분율입니다.

Actions

노드의 인덱스에 대해 수행할 수 있는 작업입니다. 아이콘을 클릭하고 다음 옵션 중 하나를 선택할 수 있습니다.

이 섹션에는 해당되는 경우 Atlas Search 및 Atlas Vector Search 인덱스가 검색 노드로 진행 중인 마이그레이션 상태가 표시됩니다. 이 섹션은 현재 검색 노드로 마이그레이션하는 경우에만 표시됩니다.

Index Status by Search Node 섹션 아래의 정보 배너에 있는 View Migration Progress 링크를 클릭하면 인덱스를 검색 노드로 마이그레이션하는 진행 상황에 대한 자세한 정보를 볼 수 있습니다(노드별로).

Atlas UI는 클러스터의 각 인덱스에 대해 다음 열을 표시합니다.

설명

Database

컬렉션이 포함된 데이터베이스의 이름입니다.

Collection

인덱싱된 컬렉션의 이름입니다.

Index Name

인덱스의 이름입니다.

Index Fields

인덱싱된 필드. 동적 매핑을 활성화한 경우 값은 dynamic입니다. 정적 매핑의 경우 열에는 인덱싱된 모든 필드가 표시됩니다.

Type

인덱스의 유형입니다. 값은 다음 유형의 인덱스 중 하나일 수 있습니다.

Status

마이그레이션 상태입니다. 자세한 학습 은 검색 노드로 마이그레이션을 참조하세요.

Size

인덱스의 크기입니다.

Documents

클러스터의 검색 노드에서 마이그레이션 중과 마이그레이션 후 컬렉션의 총 문서 수에서 인덱싱된 문서의 수와 백분율입니다.

상태 열에는 검색 노드에 대한 인덱스 상태 중 하나가 표시됩니다.

상태
설명

건물

인덱스가 현재 검색 노드에서 빌드 중입니다. 새 인덱스가 빌드되는 동안 쿼리는 기존 인덱스를 계속 사용할 수 있습니다.

대기 중

인덱스가 검색 노드에 성공적으로 빌드되었지만 마이그레이션이 아직 완료되지 않았습니다. Atlas가 검색 노드에서 모든 인덱스를 성공적으로 빌드한 경우에만 마이그레이션이 완료된다는 점에 유의하세요.

준비 완료

검색 노드의 인덱스를 쿼리에 사용할 준비가 되었습니다. Atlas가 검색 노드로의 마이그레이션을 성공적으로 완료한 경우에만 표시됩니다.

실패하였습니다.

인덱스 빌드에 실패하여 별도의 검색 노드로의 마이그레이션이 중단되었습니다. 귀하의 쿼리는 기존 인덱스를 계속 사용할 수 있습니다. Atlas는 인덱스를 다시 작성하려고 시도하지만 7일 후에 시간 초과됩니다.

성공적으로 마이그레이션 하려면 노드 별 상태 세부 정보 Message 또는 인덱스 의 페이지에서 인덱스 에 대한 오류 메시지를 검토 Status Details 하고 검색 노드에서 인덱스 빌드 실패하게 하는 문제를 주소 .

새 인덱스가 검색 노드를 기반으로 구축되는 동안 쿼리는 기존 인덱스를 계속 사용할 수 있습니다. 검색 노드로의 마이그레이션 Atlas 검색 노드에 모든 인덱스를 성공적으로 빌드한 경우에만 완료됩니다. 그러면 쿼리가 검색 노드의 인덱스를 사용하도록 자동으로 라우팅됩니다.

Atlas Search 쿼리 요구 사항을 충족하도록 Atlas Search Search 인덱스 정의하는 방법을 학습 쿼리 정의를 참조하세요.

Atlas Search 인덱스 만드는 방법을 학습 Atlas Search 인덱스 만들기를 참조하세요.

이 튜토리얼에 설명된 Atlas Search 인덱스 구성에 대해 자세히 학습 다음 참조 페이지를 참조하세요.

샘플 데이터 세트에 대한 Atlas Search 인덱스를 만들고 인덱싱된 데이터에 대해 Atlas Search 쿼리를 실행 실습을 경험하려면 Atlas Search 빠른 시작을 사용해 보세요.

다양한 복잡성의 Atlas Search 인덱스를 생성하는 방법을 보여주는 이 비디오 튜토리얼을 따라해 보세요.

지속 시간 소요 시간: 15분

돌아가기

쿼리 & 인덱스