문서 메뉴

문서 홈가이드 시작

정적 필드 매핑으로 인덱스 빌드하기

In this guide, you will learn how to index only specified fields in documents by creating an index with static field mappings. Static mappings allow you to independently index fields for specific use cases such as faceting.

소요 시간: 5분

1
2
샘플 데이터 클러스터
3
1
2

Create Index를 클릭합니다.

3

Select the Visual Editor configuration method, then click Next.

4
5

For the Database and Collection, select the sample_supplies database and the sales collection. Then, click Next.

6

Click Refine Your Index in the bottom left. Then, in the Index Configurations pane, toggle off Dynamic Mapping.

7

In the Field Mappings pane, click Add Field Mapping. In the modal window, select storeLocation from the Field Name dropdown menu.

8

From the Data Type dropdown menu, select String. Leave the Index Configurations values unchanged, and click Add at the bottom of the modal window.

4
1

On the Search Tester page, type London into the search bar, then click Search.

2

This query returns all documents in the sales collection with a storeLocation of London. Your results should resemble the following sample documents:

SCORE: 0.8888952136039734
salesDate: 2017-12-03T18:39:48.253+00:00
items: Array
storeLocation: "London"
SCORE: 0.8888952136039734
salesDate: 2015-05-15T13:43:24.561+00:00
items: Array
storeLocation: "London"
SCORE: 0.8888952136039734
salesDate: 2016-02-06T09:35:02.820+00:00
items: Array
storeLocation: "London"

Each record also includes a relevance score. You can expand Array and Object fields to view their contents by clicking on them.

3

Click Edit Query Syntax. The modal window displays the query sent through the Atlas Search API.

4

Type online into the search bar, then click Search.

Even though some records include the string online in the purchaseMethod field, no records appear. The index only has a mapping for the storeLocation field, which means that Atlas Search only returns records with matching values in the storeLocation field.

If you successfully completed the procedure in this guide, you have created an Atlas Search index with a static field mapping and used it to perform a targeted relevance-based search. In the next guide, you will learn how to perform compound searches against specific fields using the aggregation pipeline.

마지막으로
복합 연산자로 쿼리하기
5분

Retrieve documents in MongoDB with a query on multiple fields.

시작 가이드
3장
Atlas Search
  • 동적 인덱스 빌드하기
  • 정적 필드 매핑으로 인덱스 빌드하기
  • 복합 연산자로 쿼리하기
  • 패싯으로 쿼리하기
가이드 시작 →