انتقل إلى المحتوى
أمين أبوزيد
MID-043

أنظمة البحث

  • 6 درس
  • 2.5 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • البحث النصي الكامل (Full-text Search)
  • الفهارس المعكوسة (Inverted Indexes)
  • أساسيات Elasticsearch/OpenSearch

تعلّم أولًا

2.5 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Explain inverted indexes, analyzers, tokenization, and relevance scoring.
  2. Index documents and run full-text, filtered, and faceted queries in OpenSearch/Elasticsearch.
  3. Keep a search index in sync with the source of truth via events.
  4. Compare PostgreSQL full-text search with a dedicated engine.

الدروس

  1. 01كيف تجد محركات البحث الأشياء
  2. 02المحلّلات (Analyzers) والصلة
  3. 03الاستعلامات والمرشّحات والأوجه (Facets)
  4. 04إبقاء الفهرس متزامنًا
  5. 05البحث النصي الكامل في PostgreSQL مقابل محرك بحث
  6. 06عرض عملي: بحث المنتجات مع تحمّل الأخطاء الإملائية والأوجه

المختبر والتمارين

Lab

MID-043-LAB1 · Shop search

Outcomes: 1–4 · Time: ~2.5 h Build a search service: an OpenSearch index fed by ProductUpdated events, with typo tolerance and category and price facets. Write a runbook for reindexing from scratch (new index, bulk load, alias switch). Add a short note comparing PostgreSQL full-text with this setup for Shop. Acceptance: reindex from scratch documented; search never becomes the source of truth.

Exercises (assessment: lab plus tool-choice scenario)

IDOutcomeTask
MID-043-EX011Build the inverted index for three short product names and answer the query "red shoe".
MID-043-EX021Explain what changes if the analyzer lowercases and stems, using the text "Running Shoes".
MID-043-EX032Write a query: text search for "wireless headphones", category filter, price at most 200, and a category facet.
MID-043-EX043Describe an event flow that keeps the index in sync and explain how deletions and out-of-order events are handled.
MID-043-EX054Tool choice: a 5 000-product shop wants simple name search; another has 5 million with facets and typo tolerance. Choose for each.
أظهر الحلول
  • EX01 red → {1,3}; shoe → {1,2,3} (assuming docs 1 and 3 contain "red"); result docs 1 and 3.
  • EX02 Tokens become run, shoe; queries "run" and "SHOE" match. Danger: unrelated words sharing a stem can match.
  • EX03 bool with must: match name, filter: [term category, range price lte 200], and aggs.terms on category (keyword).
  • EX04 Outbox → broker → indexer upserts by product id; ProductDeleted deletes the document; use the product version as external version so older events are ignored.
  • EX05 5 000 products with simple search: PostgreSQL full-text (no extra system). 5 million with facets and fuzziness: dedicated engine.

Outcome 3 is also covered by the lab (events feed the index; reindex documented).

الاختبار

Outcomes: O1 inverted index and relevance · O2 queries and facets · O3 keeping the index in sync · O4 PostgreSQL vs engine.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1An inverted index maps:O1
  2. 2An analyzer typically does:O1
  3. 3Stemming helps match:O1
  4. 4Filters in a bool query are:O2
  5. 5Facets show:O2
  6. 6Typo tolerance in a match query uses:O2
  7. 7Best way to sync products to the index:O3
  8. 8To reindex from scratch with little downtime:O3
  9. 9An advantage of PostgreSQL full-text:O4
  10. 10A reason to adopt a dedicated engine:O4

الجزء العملي

Lab MID-043-LAB1 plus a tool-choice scenario (MID-043-EX05). Pass: quiz at least 8/10, lab with documented reindex and no dual writes, and justified tool choices.

أخطاء شائعة

Dual writes to database and index; using search as primary storage.

التقييم

Lab plus tool-choice scenario.

الصلة بالمسار الوظيفي

Data platform integration (SRB-007).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.