Bird
0
0

You want to enable full-text search on a comments field but also allow exact match filters on the same field. How should you define the mapping?

hard🚀 Application Q9 of 15
Elasticsearch - Mappings and Data Types
You want to enable full-text search on a comments field but also allow exact match filters on the same field. How should you define the mapping?
AUse a multi-field mapping with <code>text</code> type for full-text and <code>keyword</code> type for exact matches
BDefine the field only as <code>keyword</code> type to support both searches
CSet the field type as <code>text</code> and disable indexing
DUse <code>integer</code> type since it supports both search types
Step-by-Step Solution
Solution:
  1. Step 1: Understand search requirements

    Full-text search requires analyzed text, exact matches require keyword type.
  2. Step 2: Use multi-fields

    Multi-fields allow one field to be indexed in multiple ways.
  3. Step 3: Define mapping

    Map comments as text with a subfield of keyword type.
  4. Final Answer:

    Use a multi-field mapping with text type for full-text and keyword type for exact matches -> Option A
  5. Quick Check:

    Multi-fields enable both analyzed and exact searches [OK]
Quick Trick: Multi-fields support both full-text and exact match [OK]
Common Mistakes:
MISTAKES
  • Using only keyword type loses full-text search capability
  • Disabling indexing prevents searching
  • Using integer type for text fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes