أنظمة البحث
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- البحث النصي الكامل (Full-text Search)
- الفهارس المعكوسة (Inverted Indexes)
- أساسيات Elasticsearch/OpenSearch
تعلّم أولًا
2.5 ساعة تدريب (تقدير)
مخرجات التعلم
- Explain inverted indexes, analyzers, tokenization, and relevance scoring.
- Index documents and run full-text, filtered, and faceted queries in OpenSearch/Elasticsearch.
- Keep a search index in sync with the source of truth via events.
- Compare PostgreSQL full-text search with a dedicated engine.
الدروس
المختبر والتمارين
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)
| ID | Outcome | Task |
|---|---|---|
| MID-043-EX01 | 1 | Build the inverted index for three short product names and answer the query "red shoe". |
| MID-043-EX02 | 1 | Explain what changes if the analyzer lowercases and stems, using the text "Running Shoes". |
| MID-043-EX03 | 2 | Write a query: text search for "wireless headphones", category filter, price at most 200, and a category facet. |
| MID-043-EX04 | 3 | Describe an event flow that keeps the index in sync and explain how deletions and out-of-order events are handled. |
| MID-043-EX05 | 4 | Tool 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
boolwithmust: match name,filter: [term category, range price lte 200], andaggs.termsoncategory(keyword). - EX04 Outbox → broker → indexer upserts by product id;
ProductDeleteddeletes 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.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
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).