Member-only story

A poor man’s Type Ahead Search API

Suresh Kandula
2 min readMar 30, 2020

--

That dreaded Search bar in your application, it is almost always an afterthought in an enterprise setting and almost always comes back to bite you (know where it does)!

Photo by Michael Dziedzic on Unsplash

I was working with one such setting with a colleague of mine and I thought I will share a quick and dirty but a scalable and hopefully resilient approach.

Before we delve into the code, a few key points on the requirements and tech stack:

Requirements for the API:

  1. Provide Type Ahead for 100K or more search strings (structured hits and corresponding context-sensitive landing page URLs)
  2. Even a single letter typed in the search bar should show results (e.g., Type “T” — we need to show Employees, Company Names, Geographical Areas)
  3. Case insensitive
  4. Show a maximum of 20 (or configurable) search results per match (change in text value in the input box)

This is the core part of the bean code — in this case, I have copied the core part of the code as command-line utility, but you could embed in your Spring boot business logic.

--

--

Suresh Kandula
Suresh Kandula

Written by Suresh Kandula

#FinancialServices #Automotive #Architecture #LoveOfCoding

Responses (1)