Reputation: 10530
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
river newyork
instead of new river newyork
) which
can be combination of partial hotel name and city?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 :-
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 ?
Upvotes: 4
Views: 1517
Reputation: 792
Elasticsearch can be used as cache or an searchengine. By default elasticsearch index data is persistent (filesystem), you can also configure it for memorymap
Refer below for various File system storage Types https://www.elastic.co/guide/en/elasticsearch/reference/6.3/index-modules-store.html
ElastiCache is an in-memory data store service provided by Amazon (AWS) which you can use for caching.
Your proposed solution of selecting Elasticsearch is a good choice since its open source it can be used on-premise or you can use cloud services. Elasticsearch would give your more control over your search compared to caching frameworks like Redis.
You can do more complex searches like giving custom Weights based on your keywords and search a result. e.g. For your case search for Hotels, you can create any possible filters flexibly like Pricing Class, With Parking, With Balcony...etc.
But the main thing is you need to build the index from your datasource and the index would serve your site. Where as in cache your cache is getting build whenever you make queries to datasources.
Upvotes: 2