0Pricing
Elasticsearch & Full Text Search Systems · 강의

필드 매핑 사용자 지정

텍스트, 키워드, 숫자, 날짜, 부울 필드를 비롯한 다양한 필드 유형의 명시적 매핑을 정의하는 방법을 심층적으로 알아봅니다.

필드 매핑 사용자 지정은(는) CoddyKit의 무료 Elasticsearch & Full Text Search Systems 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Elasticsearch & Full Text Search Systems 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Elasticsearch & Full Text Search Systems 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Why Customize Mappings?

Elasticsearch is smart! It often guesses your data types when you index a document (this is called dynamic mapping). But sometimes, you need more precise control.

Explicit mappings let you define exactly how each field in your documents should be stored and indexed. This is crucial for optimal search behavior, efficient storage, and accurate aggregations.

Defining Your Index's Blueprint

A mapping acts like a schema for your index. You typically define it when you create a new index. It lives within the "mappings" object in your index creation request.

Here's the basic structure:

PUT /my_new_index
{
  "mappings": {
    "properties": {
      "your_field_name": {
        "type": "field_type_here"
      }
    }
  }
}

The "properties" object holds all your field definitions.

The 'text' Field Type

The text field type is designed for full-text search. Think of blog post content, product descriptions, or comments.

When you index data into a text field, Elasticsearch "analyzes" it:

  • Breaks it into individual words (tokens).
  • Converts words to lowercase.
  • Removes common words (stop words) if configured.

This process makes text highly searchable but means it's not suitable for exact matching, filtering, or sorting.

The 'keyword' Field Type

The keyword field type is for exact values that should remain as-is, without analysis. Use it when you need precise matching, filtering, or sorting.

Examples of data suitable for keyword fields:

  • Product IDs (e.g., "PROD-123")
  • Tags (e.g., "new_arrival")
  • Usernames (e.g., "john_doe")
  • Status codes (e.g., "active", "pending")

keyword fields are very efficient for aggregations and exact filters.

'text' vs. 'keyword' Example

Let's illustrate the difference. Imagine indexing a blog post with a title and a tag:

PUT /my_blog_posts
{
  "mappings": {
    "properties": {
      "title": { "type": "text" },
      "tag":   { "type": "keyword" }
    }
  }
}

Searching for "quick brown" in title would find "The quick brown fox". Searching for "quick brown" in tag would only match if the tag was *exactly* "quick brown".

Numeric Field Types

Elasticsearch provides various numeric types to store whole numbers and decimals efficiently. Choosing the right type saves space and optimizes query performance.

  • Whole Numbers: long, integer, short, byte. Use integer for age, long for large IDs.
  • Decimal Numbers: double, float, half_float, scaled_float. Use float or double for prices or measurements.

For example, "age": { "type": "integer" }.

Date Field Type

The date field type is used for storing dates and times. Elasticsearch supports many standard date formats by default, like ISO 8601.

You can also define a custom format if your dates are in a specific pattern:

"publish_date": {
  "type": "date",
  "format": "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
}

Dates are internally stored as milliseconds since the epoch, which allows for efficient range queries and sorting.

Boolean Field Type

The boolean field type is simple and efficient for storing true or false values. It's perfect for binary flags or status indicators.

For example, to indicate if a product is currently available:

"is_available": {
  "type": "boolean"
}

Elasticsearch accepts various representations for true/false, such as "true", "false", "T", "F", "on", "off", "yes", "no", "1", "0".

A Full Custom Mapping Example

Let's combine what we've learned to create a comprehensive mapping for a typical e-commerce product index:

PUT /products_catalog
{
  "mappings": {
    "properties": {
      "product_id":     { "type": "keyword" },
      "name":           { "type": "text" },
      "description":    { "type": "text" },
      "price":          { "type": "float" },
      "stock_quantity": { "type": "integer" },
      "category":       { "type": "keyword" },
      "release_date":   { "type": "date", "format": "yyyy-MM-dd" },
      "is_featured":    { "type": "boolean" }
    }
  }
}

Mapping Quiz

A field named "order_id" stores unique transaction identifiers like "TXN-2023-007". You need to be able to filter and sort orders by this ID precisely. Which field type is most appropriate?

Recap: Custom Mappings

Great job! You've taken a deep dive into explicitly defining field mappings in Elasticsearch.

We covered:

  • Why custom mappings are essential for precise control.
  • The basic structure for defining index mappings.
  • Key field types: text, keyword, numeric, date, and boolean.
  • How to choose the right type for your specific data needs.

Customizing mappings is a fundamental skill for building efficient and powerful search applications!

자주 묻는 질문

“필드 매핑 사용자 지정” 강의는 무료인가요?

네 — “필드 매핑 사용자 지정” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Elasticsearch & Full Text Search Systems 강의 전체를 잠금 해제할 수 있습니다. Elasticsearch & Full Text Search Systems 강의에는 총 4개의 강의가 포함되어 있습니다.

“필드 매핑 사용자 지정”에서 뭘 배우나요?

텍스트, 키워드, 숫자, 날짜, 부울 필드를 비롯한 다양한 필드 유형의 명시적 매핑을 정의하는 방법을 심층적으로 알아봅니다. 브라우저에서 직접 실행하는 실습 코드로 Elasticsearch & Full Text Search Systems을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Elasticsearch & Full Text Search Systems을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Elasticsearch & Full Text Search Systems은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“필드 매핑 사용자 지정” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Elasticsearch & Full Text Search Systems 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Elasticsearch & Full Text Search Systems 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 필드 매핑 사용자 지정
  2. 동적 매핑과 명시적 매핑 비교
  3. 인덱스 템플릿 및 별칭
  4. 중첩 및 객체 필드 유형
← Elasticsearch & Full Text Search Systems(으)로 돌아가기