နားလည်ထားရမယ့် အချက်
Lesson 8 က `text` vs `keyword`, dates, numbers field types ကို deep dive လုပ်ခဲ့ပြီး Lesson 21 project က Tutorial Platform index တစ်ခုလုံးကို hands-on design ခဲ့ပါတယ်—ဒီ exercise ကတော့ ဒီ decision-making process ကို domain အသစ်တစ်ခု (product catalog) အပေါ် independent အနေနဲ့ ကိုယ်တိုင် ထပ်လုပ်ကြည့်ဖို့ ဖြစ်ပါတယ်—full running app ဆောက်စရာမလိုဘဲ mapping JSON ကို design လုပ်ရုံ ဖြစ်ပါတယ်။ Field တစ်ခုချင်းစီအတွက် decision ကို systematic လုပ်ဖို့ question တွေ မေးရပါမယ်—field ဒီကို full-text search (`text`) လိုသလား၊ exact match/filter/aggregation (`keyword`) လိုသလား၊ numeric range query (`integer`/`float`) လိုသလား၊ date math (`date`) လိုသလား ဆိုတာ field တစ်ခုချင်းစီအတွက် ဆုံးဖြတ်ရပါမယ်။ `price` field ကတော့ interesting edge case ဖြစ်ပါတယ်—numeric range query (`WHERE price < 50`) လိုအပ်လို့ numeric type (`float`/`scaled_float`) ရွေးရမယ်ဆိုတာ ရှင်းပေမယ့် money precision issue ကို floating-point rounding error ကနေ ကာကွယ်ဖို့ `scaled_float` (integer အဖြစ် internally သိမ်းပြီး scaling factor ဖြင့် decimal simulate) ကို consider လုပ်သင့်ပါတယ်—ဒါက Redis course ရဲ့ "money ကို floating score အဖြစ် သိမ်းရင် accounting-grade precision မရ" ဆိုတဲ့ lesson ကို directly ပြန် echo လုပ်နေတာပါ။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Product catalog index ရဲ့ field တစ်ခုစီကို requirement analysis ဆောင်ရွက်မယ်—`name` (product title, search box မှာ full-text search + admin sort အတွက် exact match) ကို `text` + `.keyword` sub-field (Lesson 8 ရဲ့ multi-field pattern) နဲ့ design မယ်၊ `description` (long-form text, full-text search ချည်းသာလို) ကို plain `text` ထားမယ်၊ `price` (range filter + exact-value comparison) ကို `scaled_float` (scaling factor 100) ထားမယ်၊ `category` (dropdown value, exact filter/facet) ကို `keyword` ထားမယ်၊ `tags` (multiple values, facet) ကို `keyword` array ထားမယ်။
အတူတူ စမ်းရေးကြည့်မယ်
// Your task: complete this mapping for a product catalog index.
PUT /products
{
"mappings": {
"properties": {
"name": { /* your design here */ },
"description": { /* your design here */ },
"price": { /* your design here */ },
"category": { /* your design here */ },
"tags": { /* your design here */ }
}
}
}Product catalog ရဲ့ field ငါးခုအတွက် ကိုယ်တိုင်ဒီဇိုင်းရေးဆွဲထားသော complete mapping JSON ရမည်။၅ မိနစ် စမ်းကြည့်
အပေါ်က starter mapping ကို ပြည့်စုံအောင်ဆက်ရေးပါ—field တစ်ခုချင်းစီအတွက် ရွေးချယ်ခဲ့တဲ့ type ကို ဘာကြောင့်ရွေးလဲဆိုတဲ့ တစ်ကြောင်းစီ comment ပါထည့်ပါ။
သတိလေးတစ်ချက်
`price` field ကို `text` သို့ `keyword` type အဖြစ် mapping လုပ်ခြင်း—range query (`price < 50`)၊ `avg`/`sum` aggregation များ run လို့ လုံးဝမရတော့ပါ။
`category` field ကို `text` type အဖြစ် mapping လုပ်ခြင်း—admin dashboard ရဲ့ "category တစ်ခုစီအတွက် product count" `terms` aggregation ကို run ရင် category word တစ်ခုချင်းစီ (category name ထဲက word အသီးသီး) အတွက် bucket ခွဲသွားပြီး intended result မရနိုင်ပါ။
Elasticsearch Guide — Field Data Types — Elastic