Bird
0
0

You want to create an index users with a field age that should only accept whole numbers and be searchable. Which mapping is correct?

hard🚀 Application Q15 of 15
Elasticsearch - Index Management
You want to create an index users with a field age that should only accept whole numbers and be searchable. Which mapping is correct?
A{ "mappings": { "properties": { "age": { "type": "float" } } } }
B{ "mappings": { "properties": { "age": { "type": "text" } } } }
C{ "mappings": { "properties": { "age": { "type": "integer" } } } }
D{ "mappings": { "properties": { "age": { "type": "keyword" } } } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand the data type needed for age

    Age is a whole number, so integer type is appropriate to store numeric whole values.
  2. Step 2: Check searchability and field types

    Text is for full text search, float allows decimals, keyword is for exact matches but not numeric operations.
  3. Final Answer:

    { "mappings": { "properties": { "age": { "type": "integer" } } } } -> Option C
  4. Quick Check:

    Whole number field = integer type [OK]
Quick Trick: Use integer type for whole number searchable fields [OK]
Common Mistakes:
MISTAKES
  • Using text type for numeric fields
  • Choosing float when decimals not needed
  • Using keyword for numeric data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes