Autocomplete with java , Redis, Elastic Search , Mongo

It’s a critical search use case, and MongoDB and Redis are perfect for key-based lookups and not use for Search purposes, while Elasticsearch is a distributed search engine, built specifically for such use-case.

Before choosing the system, you should know how your feature works internally And below the consideration for selecting it.

Non-functional requirements for your feature

  1. What would be the total no of search queries per second (QPS)?
  2. How frequently you would be updating the documents(ie, names in your example).
  3. What is the SLA after names in updated and coming in the search result?
  4. SLA for your search results.

Some functional requirements.

  1. How autocomplete should look like, prefix, infix search on names?
  2. Minimum how many character user should type, before showing them the autocomplete results.
  3. How frequently the above requirements can change.

Elasticsearch indexed documents in the inverted index and works on
tokens match(which can be easily customized to suit business
requirements), hence super fast in searching. Redis and MongoDB are
not having this structure internally and shouldn’t be used for this
use-case. You shouldn’t have any doubt about choosing Elasticsearch over
these to implement Autocomplete.

Leave a Comment