Thuta Learning
ရှာဖွေရန်
Elasticsearch
BasicData & Databasesbeginner

Getting Started — Elasticsearch Course လမ်းညွှန်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Getting Started — Elasticsearch Course လမ်းညွှန် concept ကို နားလည်ရှင်းပြနိုင်ရန်
  • နမူနာ Elasticsearch query/code ကို ကိုယ်တိုင် run ပြီး output စစ်နိုင်ရန်
  • Tutorial Platform project နှင့် production scenario တွင် မှန်ကန်စွာအသုံးချနိုင်ရန်

နားလည်ထားရမယ့် အချက်

Elasticsearch က document များကို JSON format နဲ့သိမ်းပြီး inverted index ဆိုတဲ့ data structure ကိုအသုံးပြုကာ text ထဲက word များကို extremely fast ရှာဖွေပေးနိုင်တဲ့ search နှင့် analytics engine တစ်ခုဖြစ်ပါတယ်။ PostgreSQL လို relational database တစ်ခုမှာ `LIKE '%keyword%'` သို့မဟုတ် basic full-text search extension တွေသုံးရင်တောင် table ကြီးလာတာနဲ့အမျှ query နှေးလာတတ်ပြီး၊ typo tolerance၊ relevance ranking (ဘယ် result က ပိုသက်ဆိုင်လဲ)၊ synonym matching စတာတွေကို native အနေနဲ့ ကောင်းကောင်းမလုပ်ပေးနိုင်ပါဘူး။ Elasticsearch ကတော့ ဒီပြဿနာတွေအတွက်ဘဲ design လုပ်ထားတာဖြစ်လို့ text field များကို indexing လုပ်တဲ့အချိန်မှာပဲ token (word) အသေးလေးတွေအဖြစ် ခွဲပြီး inverted index ဆောက်ထားတာကြောင့် millions of documents ထဲက relevant result တွေကို milliseconds အတွင်း ရှာပေးနိုင်ပါတယ်။ Elasticsearch ကို database အစားထိုးအဖြစ်မသုံးဘဲ existing database (ဒီ course မှာ PostgreSQL) ဘေးမှာ specialized search layer တစ်ခုအနေနဲ့ ထားတွဲသုံးလေ့ရှိပါတယ်—source of truth data က PostgreSQL မှာနေဆဲဖြစ်ပြီး search-optimized copy တစ်ခုကိုသာ Elasticsearch ဘက် sync ပို့ထားတာပါ။ ဒါကို library book catalog တစ်ခုနဲ့ တွေးကြည့်ရင် တွေးလို့ရပါတယ်—PostgreSQL က book တိုင်းရဲ့ official record (title, author, ISBN, availability) ကိုတိကျစွာသိမ်းထားတဲ့ master ledger ဖြစ်ပြီး Elasticsearch ကတော့ book content တစ်အုပ်လုံးကို topic/keyword အလိုက် အလျင်အမြန်ရှာနိုင်တဲ့ card-index catalog တစ်ခုနဲ့တူပါတယ်။ ဒီ course တစ်ခုလုံးက installation/basics ကနေစပြီး mapping, Query DSL, aggregations ကို ဖြတ်ကာ production concerns (security, performance, cluster architecture) အထိ တစ်ဆင့်ချင်း တက်သွားမှာဖြစ်ပါတယ်။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

ဒီ course တစ်ခုလုံးမှာ Tutorial Platform ဆိုတဲ့ PostgreSQL-backed course/lesson catalog project တစ်ခုကို running example အဖြစ်သုံးသွားမယ်—Redis course မှာ cache/session layer အဖြစ်ထည့်ခဲ့ပြီး ဒီ course မှာတော့ full-text search layer ထပ်ထည့်မယ်။ PostgreSQL မှာ tutorial title, lesson body text, tags တွေကို ရှာချင်တဲ့အခါ `ILIKE '%redis%'` လို query တွေက tutorial count များလာတာနဲ့အမျှ နှေးလာမယ်၊ ပြီးတော့ user က "redi cache" လို typo ပါတဲ့ search လုပ်ရင် result လုံးဝမရနိုင်ပါဘူး။ ဒီအစား Elasticsearch index တစ်ခုကို PostgreSQL ကနေ sync ဆွဲပြီး search UI အားလုံးက ဒီ index ကို query လုပ်ပြီး result ပြန်ရမယ်—PostgreSQL ကတော့ ဆက်လက်ပြီး create/edit/delete operations အားလုံးရဲ့ source of truth အဖြစ်ကျန်နေမယ်။ Lesson တစ်ခုပြီးတိုင်း ဒီ search backend ကို layer တစ်ခုချင်း တည်ဆောက်သွားမယ်—installation, mapping, indexing, querying, aggregations, client integration အထိ။

အတူတူ စမ်းရေးကြည့်မယ်

text
PostgreSQL (source of truth)
  tutorials, lessons, tags tables
        |
        |  sync (bulk index / CDC)
        v
Elasticsearch index ("tutorials")
  inverted index over title, body, tags
        |
        |  search queries (Query DSL)
        v
Tutorial Platform search UI
  instant, typo-tolerant, ranked results
You should see
Elasticsearch က ဘယ်ပြဿနာကိုဖြေရှင်းလဲနှင့် ဒီ course ရဲ့ project ကို ရှင်းပြနိုင်မည်။

၅ မိနစ် စမ်းကြည့်

မိမိသုံးဖူးတဲ့ website တစ်ခုရဲ့ search box ကို စဉ်းစားပြီး၊ typo ပါတဲ့ search term တစ်ခုနဲ့ ရှာကြည့်ရင် ဘာဖြစ်လိမ့်မလဲ (result ရ/မရ) ခန့်မှန်းရေးပါ။ PostgreSQL `LIKE` query တစ်ခုတည်းနဲ့ ဒီလို typo tolerance ရအောင် ဘာကြောင့်ခက်ခဲလဲ ဆင်ခြင်ချက် သုံးချက်ရေးပါ။

သတိလေးတစ်ချက်

Elasticsearch ကို PostgreSQL ရဲ့ လုံးဝအစားထိုးအဖြစ် စဉ်းစားပြီး transactional data (orders, payments) တွေကိုပါ Elasticsearch ထဲပဲ တစ်ခုတည်းသိမ်းဖို့ ကြိုးစားခြင်း—Elasticsearch မှာ ACID transaction support အားနည်းပါတယ်။

Sync mechanism (PostgreSQL → Elasticsearch) ကို စဉ်းစားမနေဘဲ Elasticsearch ထဲကို data manually တစ်ကြိမ်ပဲ ထည့်ပြီး PostgreSQL updates တွေ ဆက်မထင်ဟပ်ဘူးလို့ မှတ်မထားခြင်း—index က stale ဖြစ်သွားနိုင်ပါတယ်။

Elasticsearch Guide — What is Elasticsearch?Elastic

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Elasticsearch ကို PostgreSQL ရဲ့ လုံးဝအစားထိုးအဖြစ် စဉ်းစားပြီး transactional data (orders, payments) တွေကိုပါ Elasticsearch ထဲပဲ တစ်ခုတည်းသိမ်းဖို့ ကြိုးစားခြင်း—Elasticsearch မှာ ACID transaction support အားနည်းပါတယ်။
  • Sync mechanism (PostgreSQL → Elasticsearch) ကို စဉ်းစားမနေဘဲ Elasticsearch ထဲကို data manually တစ်ကြိမ်ပဲ ထည့်ပြီး PostgreSQL updates တွေ ဆက်မထင်ဟပ်ဘူးလို့ မှတ်မထားခြင်း—index က stale ဖြစ်သွားနိုင်ပါတယ်။
  • နမူနာ query/mutation ကို production cluster ပေါ် တိုက်ရိုက်မစမ်းဘဲ local/test instance နှင့် recoverable data ပေါ်တွင် အရင်အတည်ပြုပါ။

လေ့ကျင့်ခန်း

မိမိသုံးဖူးတဲ့ website တစ်ခုရဲ့ search box ကို စဉ်းစားပြီး၊ typo ပါတဲ့ search term တစ်ခုနဲ့ ရှာကြည့်ရင် ဘာဖြစ်လိမ့်မလဲ (result ရ/မရ) ခန့်မှန်းရေးပါ။ PostgreSQL `LIKE` query တစ်ခုတည်းနဲ့ ဒီလို typo tolerance ရအောင် ဘာကြောင့်ခက်ခဲလဲ ဆင်ခြင်ချက် သုံးချက်ရေးပါ။

You'll know it worked when: Elasticsearch က ဘယ်ပြဿနာကိုဖြေရှင်းလဲနှင့် ဒီ course ရဲ့ project ကို ရှင်းပြနိုင်မည်။

Getting Started — Elasticsearch Course လမ်းညွှန် | Thuta Learning