Bird
Raised Fist0
HLDsystem_design~20 mins

Search and metadata in HLD - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Search and Metadata Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Designing a scalable search system for metadata-rich documents

You need to design a search system that indexes documents with rich metadata (tags, authors, dates). Which architecture best supports fast, scalable search with frequent metadata updates?

AUse a distributed search engine like Elasticsearch with separate indices for metadata and content.
BUse a relational database with full-text search and update metadata in place.
CStore documents in a NoSQL key-value store and perform search by scanning all keys.
DUse a file system with metadata stored in separate JSON files and search by reading files sequentially.
Attempts:
2 left
💡 Hint

Think about systems optimized for search and handling frequent updates efficiently.

scaling
intermediate
2:00remaining
Estimating capacity for a metadata search service

Your metadata search service expects 10 million documents with an average of 20 metadata fields each. You expect 1000 queries per second. What is the best way to estimate the required hardware capacity?

AEstimate index size for metadata, average query complexity, and use benchmarks of similar systems to size CPU and memory.
BCalculate storage size for all metadata and content, then multiply by query rate to get CPU needs.
CCount number of documents only and assign one CPU core per 1000 documents.
DIgnore metadata size and focus only on network bandwidth for query traffic.
Attempts:
2 left
💡 Hint

Consider both data size and query complexity, and use real-world benchmarks.

tradeoff
advanced
2:00remaining
Choosing between inverted index and graph database for metadata search

You must choose a data structure for searching documents by metadata. Which option best fits a use case with complex relationships between metadata (e.g., authors collaborating, hierarchical tags)?

AUse a relational database with multiple join tables for metadata relationships.
BUse an inverted index optimized for keyword search across metadata fields.
CUse a simple key-value store with metadata serialized as JSON strings.
DUse a graph database to model and query complex relationships between metadata entities.
Attempts:
2 left
💡 Hint

Consider which data structure naturally represents relationships and supports complex queries.

🧠 Conceptual
advanced
2:00remaining
Understanding metadata freshness impact on search results

In a search system with frequent metadata updates, what is the main tradeoff when choosing between real-time indexing and batch indexing?

AReal-time indexing reduces query latency but increases network bandwidth; batch indexing reduces bandwidth usage.
BBatch indexing improves freshness but requires more storage; real-time indexing reduces storage needs.
CReal-time indexing improves freshness but increases system load; batch indexing reduces load but delays updates.
DBatch indexing allows partial updates; real-time indexing requires full reindexing each time.
Attempts:
2 left
💡 Hint

Think about how update frequency affects system performance and data freshness.

component
expert
3:00remaining
Request flow in a distributed metadata search system

Trace the request flow when a user searches for documents by metadata in a distributed search system with multiple shards and a metadata cache layer. Which sequence correctly describes the flow?

A1, 3, 4, 2, 5, 6
B1, 2, 3, 4, 5, 6
C1, 2, 4, 3, 5, 6
D1, 3, 2, 4, 5, 6
Attempts:
2 left
💡 Hint

Consider cache lookup before querying shards and updating cache after aggregation.

Practice

(1/5)
1. What is the primary purpose of metadata in a search system?
easy
A. To display images on the website
B. To store user passwords securely
C. To describe data and make search faster
D. To manage network connections

Solution

  1. Step 1: Understand metadata role

    Metadata provides information about data, like tags or descriptions.
  2. Step 2: Connect metadata to search

    Search engines use metadata to quickly find relevant data without scanning everything.
  3. Final Answer:

    To describe data and make search faster -> Option C
  4. Quick Check:

    Metadata = Data description for search [OK]
Hint: Metadata helps find data faster by describing it [OK]
Common Mistakes:
  • Confusing metadata with user data
  • Thinking metadata stores passwords
  • Assuming metadata manages network
2. Which of the following is a correct example of metadata used in search?
easy
A. title = 'Introduction to Cats'
B. file_size = 2048
C. user_password = '1234'
D. connection_timeout = 30

Solution

  1. Step 1: Identify metadata examples

    Metadata describes content, like titles, tags, or dates.
  2. Step 2: Check each option

    title = 'Introduction to Cats' shows a title, which is metadata describing content. Others are config or sensitive data.
  3. Final Answer:

    title = 'Introduction to Cats' -> Option A
  4. Quick Check:

    Title is metadata for search [OK]
Hint: Metadata describes content, not configs or passwords [OK]
Common Mistakes:
  • Choosing config values as metadata
  • Confusing sensitive data with metadata
  • Ignoring descriptive fields
3. Given a search system with metadata index, what is the expected output when searching for "apple" if metadata contains {"title": "apple pie", "tags": ["fruit", "dessert"]}?
medium
A. No results found
B. Returns item with title "apple pie"
C. Returns all items with tag "fruit" only
D. Returns items with tag "dessert" only

Solution

  1. Step 1: Understand search with metadata

    Search looks for matches in metadata fields like title and tags.
  2. Step 2: Check if "apple" matches metadata

    "apple" matches the title "apple pie", so the item is returned.
  3. Final Answer:

    Returns item with title "apple pie" -> Option B
  4. Quick Check:

    Search matches title containing "apple" [OK]
Hint: Search matches metadata fields containing query word [OK]
Common Mistakes:
  • Ignoring title field in search
  • Returning unrelated tags only
  • Assuming no results if exact match missing
4. A search system's metadata index is not returning expected results. Which issue below is most likely the cause?
medium
A. Database password is incorrect
B. User interface colors are dull
C. Network cables are unplugged
D. Metadata is not updated after data changes

Solution

  1. Step 1: Identify cause of search failure

    If metadata is stale, search index won't reflect latest data.
  2. Step 2: Evaluate options

    Only Metadata is not updated after data changes relates to metadata and search correctness; others are unrelated.
  3. Final Answer:

    Metadata is not updated after data changes -> Option D
  4. Quick Check:

    Stale metadata breaks search results [OK]
Hint: Keep metadata updated to ensure correct search [OK]
Common Mistakes:
  • Blaming UI or network for search logic errors
  • Ignoring metadata update process
  • Confusing unrelated system issues
5. You are designing a scalable search system for millions of users. Which approach best ensures fast search using metadata?
hard
A. Use distributed indexing with metadata shards and update indexes asynchronously
B. Store metadata in a centralized database and scan all records on each search
C. Keep metadata only on user devices and search locally
D. Disable metadata to reduce storage and search raw data only

Solution

  1. Step 1: Understand scalability needs

    Millions of users require fast, distributed search to avoid bottlenecks.
  2. Step 2: Evaluate options for scalability

    Use distributed indexing with metadata shards and update indexes asynchronously uses distributed indexing and async updates, which scales well and keeps search fast.
  3. Final Answer:

    Use distributed indexing with metadata shards and update indexes asynchronously -> Option A
  4. Quick Check:

    Distributed indexing + async updates = scalable search [OK]
Hint: Distribute metadata index and update asynchronously for scale [OK]
Common Mistakes:
  • Scanning all data centrally causes slow search
  • Relying on local device metadata limits scale
  • Disabling metadata removes search efficiency