I need to design the feature like in ecommerce(consider hotel booking site) we can enter the keyword/partial-keyword and need to return the relevant results. For Example :- If site admin or hotel owner needs to add the below hotel details in system , It will be added in cache also(basically it will be write through cache).
Hotel-Name: New River
City: NewYork
Rating:4 Star
Rate($):500
My question is how to design the below points in the system
- Do I need to store the Hotel data in cache as key value pair may be using Redis or Memcache ? What will be the key and value ?
- If I store it as key value pair, how will I serach using partial keyword(like entering
river newyork
instead ofnew river newyork
) which can be combination of partial hotel name and city? - What can be possible sharded key to distribute the data in cache ?
Consider this system as scalable as Goibibo
.
My proposed solution :-
After reading below two resources, looks like I can use Elastic search(ES) for all three points mentioned above. What it will do is :-
- Create the index with name say hotel_data which will contain index on all searchable fields of hotel json document
- ES will store the index in memory
- Then I can search partial words like search partial words
Links
elasticsearch-from-the-bottom-up
elasticsearch-hello-world-example
But when I discussed this approach with CTO, he told you are mixing elastic search and elastic cache and said elastic search can be used for search and elastic cache for caching .
But when I again re- read those resources, I found elastic search is used for both caching and searching. So I found nothing wrong in my approach. Is there something in my approach ?