简体   繁体   中英

What is the recommended way to store data for search in elasticsearch

Let's say I use Elasticsearch in my application for searching restaurants near me. I get all sorted restaurants id from Elasticsearch. And using these ids, I get all data like name, location, popular menus of restaurant from RDB.

As you can guess, it takes some time to get data from RDB. If I store all data used by application in Elasticsearch, then I can make it faster. But I'm wondering what is the recommended way to store data in Elasticsearch and what to consider for choosing it.

I think there are some ways like below,

  1. To store data only used for search
  2. To store all data for search and display

Thanks!

This is a very interesting but very common question and normally every application needs to decide this, I can provide some data points which would help you to take a informed decision.

  1. Elasticsearch is a NRT search engine and there will always be some latency when you update ES from your RDB. so some of your items which are in RDB will not be in ES and thus will not be in your search results.
  2. Considering above, why you want to make a call again to RDB, to fetch the latest info from your RDB, on your ES search result or some other reasons like avoid fetching/storing the large data from ES?
  3. With every field ES provides a way to store it or not using store param or using _source enabled by default, if both are not enabled, you can't fetch the actual value, then you have to go to RDB.
  4. RDB call to fetch the values of fields put a penalty on performance, have you benchmark it versus fetching the values directly from ES.

Every search system has its own functional and non-functional requirement and based on above points, hope you got more information, which will help you take a better decision.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM