Docs Menu

인덱스 파티션 구성

이 페이지의 내용

중요

옵션은 numPartitions 미리보기 기능 으로 사용할 수 있습니다.

인덱싱을 위해, Atlas Search는 각 문서가 다른 문서 안에 중첩되어 있지 않을 때 각 문서를 단일 인덱스 object로 간주합니다. 내장된 문서의 경우, Atlas Search는 중첩 수준에 따라 각 내장된 문서를 추가 인덱스 object로 간주합니다. Atlas Search는 2,100,000,000 인덱스 object보다 큰 인덱스에 대한 변경 사항 복제를 중단합니다.

별도의 검색 노드에 Atlas Search를 배포한 경우, 인덱스 객체를 하위 인덱스로 분할하여 Atlas Search 인덱스 객체의 수를 늘릴 수 있습니다. 기본값으로 Atlas Search는 샤드당 하나의 파티션을 지원합니다. 각 파티션은 최대 2 억 개의 인덱스 객체를 지원합니다. numPartitions 옵션을 사용하여 최대 64개(64)의 하위 인덱스를 생성할 수 있습니다.

인덱스에 대한 파티션을 구성하면 Atlas Search는 최적의 방식으로 하위 인덱스 간에 인덱스 object를 자동으로 분배합니다. 하위 인덱스가 있는 컬렉션에 대해 쿼리를 실행할 때, Atlas Search는 쿼리를 모든 하위 인덱스로 분산시키고, 검색 결과와 메타데이터를 수집하여 정렬하고 병합한 후 결과를 반환합니다.

다음과 같은 경우에는 인덱스를 분할하는 것이 좋습니다.

  • 인덱스 object가 총 한도의 50%에 도달했습니다.

  • 컬렉션의 문서 수가 20억 개에 도달했습니다.

  • Atlas Search가 복제를 중지했기 때문에 인덱스가 STALE 상태입니다.

하위 인덱스를 구성하거나 하위 인덱스의 수를 수정하면 Atlas Search가 인덱스를 다시 생성합니다.

클러스터에 하위 인덱스가 두 개 이상 있는 경우, 모든 검색 노드를 제거하고 mongodmongot 프로세스가 동일한 노드에서 실행되는 배포 모델로 전환할 수 없습니다.

{
"name": "<index-name>",
"analyzer": "<analyzer-for-index>",
"searchAnalyzer": "<analyzer-for-query>",
"mappings": {
"dynamic": <boolean>,
"fields": { <field-definition> }
},
"numPartitions": <integer>,
...
}

Atlas Search numPartitions 옵션은 다음 값을 사용합니다.

  • 1 - 추가 하위 인덱스 없이 단일 인덱스를 생성합니다. 이것이 기본값입니다.

  • 2 - 최대 두 개의 하위 인덱스를 생성합니다.

  • 4 - 최대 4개의 하위 인덱스를 생성합니다.

  • 8 - 최대 8개의 하위 인덱스를 생성합니다.

  • 16 - 최대 16개의 하위 인덱스를 생성할 수 있습니다.

  • 32 - 최대 서른두 개의 하위 인덱스를 생성합니다.

  • 64 - 최대 64개의 하위 인덱스를 생성합니다.

다음 인덱스 예제에서는 sample_mflix.movies collection을 사용하여 컬렉션의 데이터에 대해 최대 4 개의 하위 인덱스를 구성하는 방법을 보여줍니다. Atlas UI에서 비주얼 편집기 또는 JSON 편집기를 사용하거나 기타 지원되는 클라이언트 에서 인덱스를 생성할 수 있습니다.


언어 선택 드롭다운 메뉴를 사용하여 이 섹션의 예시 클라이언트를 설정합니다.


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": "movies",
"database": "sample_mflix",
"name": "partitioned_index",
"type": "search",
"definition": {
"analyzer": "lucene.standard",
"mappings": {
"dynamic": true,
},
"numPartitions": 4,
"searchAnalyzer": "lucene.standard"
}
}'
  1. indexDef.json 라는 이름의 file을 만들고 다음과 유사한 내용을 추가합니다.

    {
    "collectionName": "movies",
    "database": "sample_mflix",
    "definition": {
    "mappings": {
    "dynamic": true
    },
    },
    "name": "partitioned_index",
    "numPartitions": 4
    }
  2. 다음 명령을 실행하여 인덱스를 생성합니다.

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

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

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

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

2

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

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

    참고

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

  2. Select data source 드롭다운에서 클러스터를 선택하고 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: partitioned_index

  • Database and Collection:

    • sample_mflix database

    • movies 컬렉션

Configuration Method

For a guided experience, select Visual Editor.

To edit the raw index definition, select JSON Editor.
5
  1. Refine Your Index를 클릭합니다.

  2. Index Partitions 을 활성화하려면 토글합니다.

  3. Number of partitions 드롭다운에서 4 을(를) 선택하고 Save Changes를 클릭하세요.

  1. 기본 인덱스 정의를 다음으로 교체합니다.

    {
    "mappings": {
    "dynamic": true
    },
    "numPartitions": 4
    }
  2. Next를 클릭합니다.

6

Atlas 인덱스 작성 중임을 알려주는 토스트(간단한 비대화형 알림)를 표시합니다.

7

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

참고

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

db.movies.createSearchIndex(
"search-index",
{ mappings: { dynamic: true }, "numPartitions": 4 }
)
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("sample_mflix");
var collection = db.GetCollection<BsonDocument>("movies");
// define your Atlas Search index
var index = new BsonDocument
{
{ "mappings", new BsonDocument
{
{ "dynamic", true }
}
},
{ "numPartitions", 4 }
};
var result = collection.SearchIndexes.CreateOne(index, "partitioned_index");
Console.WriteLine(result);
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("sample_mflix");
MongoCollection<Document> collection = database.getCollection("movies");
Document index = new Document()
.append("mappings", new Document()
.append("dynamic", true)
)
.append("numPartitions", 4);
collection.createSearchIndex("partitioned_index", index);
}
}
}
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("sample_mflix");
const collection = database.collection("movies");
// define your Atlas Search index
const index = {
name: "partitioned_index",
definition: {
/* search index definition fields */
"mappings": {
"dynamic": true
},
"numPartitions": 4
}
}
// run the helper method
const result = await collection.createSearchIndex(index);
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);
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["sample_mflix"]
collection = database["movies"]
# Create your index model, then create the search index
search_index_model = SearchIndexModel(
definition={
"mappings": {
"dynamic": True
},
"numPartitions": 4
},
name="partitioned_index",
)
result = collection.create_search_index(model=search_index_model)
print(result)

이 페이지의 내용