solidcodersolidcoder
Explore Courses
solidcodersolidcoder

Practical courses for software engineering interviews — no gatekeeping, no fluff.

Company-wise Questions

  • Flipkart Machine Coding Questions
  • Swiggy Machine Coding Questions
  • Meesho Machine Coding Questions
  • Razorpay Machine Coding Questions

Machine Coding Tutorial

  • Machine Coding Tutorial

Explore

  • Courses
  • About
  • Privacy Policy
  • Terms

© 2026 solidcoder · Practical courses for software engineering interviews.

Built for the AI era — learn by doing.

Home/Machine Coding/Razorpay Machine Coding Questions/Search Engine — Razorpay Machine Coding Round
Chapters — Razorpay Machine Coding Questions▾

Search Engine — Razorpay Machine Coding Round

Machine Coding·SDE-3+·5 min read·Sep 11, 2026

Razorpay machine coding round — design a lightweight in-memory search engine with datasets, substring search, and relevance ranking.

Search Engine — Razorpay Machine Coding Round — Razorpay Machine Coding Questions
Razorpay machine coding round — design a lightweight in-memory search engine with datasets, substring search, and relevance ranking.
Asked inRazorpay

Your organization has started a new tech blog full of interesting stories, and you're responsible for designing and implementing an in-memory search engine that powers search over the blog's content.

A note on this version

The original notes were a rough sketch — a bullet list of requirements plus a worked example, not a fully worded question. This is a framed, cleaned-up version of the same problem: the requirements and example below are taken directly from those notes; the surrounding structure (edge cases, data model, walkthrough) has been filled in to make it usable as a standalone question.

What the round tests

This one tests whether you can design a clean indexing structure and get the ranking logic exactly right — the interesting part isn't finding matches, it's ordering them by how relevant each document is to the search term.

Objective

The primary objective of this project is to design and implement an in-memory search engine that organizes documents into named datasets, supports inserting and deleting documents, and returns search results ranked by relevance to the search term.

Data Model

Each dataset is conceptually a map from a document ID to its text content.

dataset "tech-blog" -> {
  doc1: "apple is a fruit",
  doc2: "apple, apple come on!",
  doc3: "oranges are sour",
  doc4: "apple-pie is sweet",
}

Functional Requirements

Two tiers of scope

Requirements are split into two tiers so you know what to prioritize under time pressure: build first, and worth proposing if time allows.

Part 1 — Basic Requirements

Core functionality you must build and get working first.

Core operations
Operation
Behavior
createDataset(datasetName)
Creates a new, empty dataset that documents can be inserted into.
insertDocument(datasetName, docId, text)
Adds a document (a plain piece of text) to the given dataset under a document ID.
deleteDocument(datasetName, docId)
Removes a document from the dataset; it should no longer appear in any future search results.
search(datasetName, term)
Returns the documents in the dataset that contain the search term, ordered by relevance (see ranking rule below).
Matching & ranking rule

A document matches if the search term appears as a substring anywhere in its text — case sensitivity is worth clarifying with the interviewer, but the example below treats it as case-sensitive. Results are ordered by descending number of occurrences of the term within each matching document; documents with the same occurrence count can be returned in either relative order.

Example Usage

Search term: apple, over this dataset:

Doc1: apple is a fruit
Doc2: apple, apple come on!
Doc3: oranges are sour
Doc4: apple-pie is sweet
> search("tech-blog", "apple")
[Doc2, Doc1, Doc4]   (or [Doc2, Doc4, Doc1] — either order is acceptable)
Result

Doc2 contains "apple" twice and ranks first. Doc1 and Doc4 each contain it once — Doc4's match comes from "apple" as a substring of "apple-pie," confirming that matching is substring-based rather than whole-word. Doc3 has no occurrences and is correctly excluded. Doc1 and Doc4 tie on occurrence count, so either relative order between them is valid.

Part 2 — Suggested Extensions

Dataset & document management
Feature
Why it's worth adding
deleteDataset(datasetName)
Symmetric to createDataset — tears down a whole dataset along with all its documents.
listDatasets() / listDocuments(datasetName)
Basic introspection — see what exists without already knowing the IDs.
Thread safety
Concurrent inserts, deletes, and searches on the same dataset shouldn't corrupt the index or return stale results.
updateDocument(datasetName, docId, text)
Edit a document's content in place instead of requiring delete-then-reinsert (and re-triggers re-indexing if you build an inverted index).
Search quality
Feature
Why it's worth adding
Case-insensitive matching option
The base example doesn't fully specify case sensitivity — offering both modes shows you noticed the gap.

Part 3 — Scale & Operations

Scale & operations
Feature
Why it's worth adding
Pagination
Return results in pages (offset/limit) instead of the full ranked list at once, for datasets with many matches.
Inverted index
Instead of scanning every document per search, maintain a term → document-ID index updated on insert/delete, so search stays fast as the dataset grows.
Result highlighting
Return the matched snippet with the term highlighted, useful if this ever backs an actual UI.
Up next1/1
Part 2 · SDE-3+
←
← Prev Chapter
Document Service
5 min

Enroll in machine coding mastery series

₹30,000₹3,00090% OFF
Enroll Now →

Use code SOLID50 · 3 years · 40+ lessons

On this page
  • Objective
  • Data Model
  • Functional Requirements
    • Part 1 — Basic Requirements
  • Example Usage
    • Part 2 — Suggested Extensions
    • Part 3 — Scale & Operations