Home  >  Article  >  Database  >  The difference between elasticsearch and redis

The difference between elasticsearch and redis

(*-*)浩
(*-*)浩Original
2019-06-18 09:13:5710776browse

The difference between elasticsearch and redis

Elasticsearch (ES)

Compared with MongoDB and Redis, ES, which was released a year later, may be less well-known. But ES's reputation in the search engine field is definitely resounding.

Course Recommendation→: "Elasticsearch Full Text Search Practical Combat" (Practical Video)

From the course"Ten Million Level Data Concurrency Solution (Theoretical and Practical)》

Compared with other high-end database products, ES has a much older background.

The founder of ES, Shay Banon, was once an unemployed programmer. He created ES to facilitate his wife’s search for recipes when he had nothing to do (of course, it was not called ES at the time). Unexpectedly, through unintentional intervention, the most popular search engine database was created today. Sure enough, girls are the biggest motivation for programmers to work!

ES has also established its own Elastic company and has received hundreds of millions of dollars in financing. Shay Banon, the loser programmer at that time, has already counterattacked to become CEO and reached the pinnacle of his life. Programmers, after reading this story, have you already begun to imagine the day when you become CEO and marry Bai Fumei?

The characteristic of ES, as its name suggests, is search. Strictly speaking, ES is not a database, but a search engine, and all aspects of ES are designed around search.

ES supports full-text search. Here is a brief explanation of what full-text search is: For data such as "I work in an Internet company in Beijing", if you search for "Beijing", "Internet", " If keywords such as "work" can hit this data, this is a full-text search. Baidu and Google that you use every day are full-text searches.

It is worth mentioning that ES’s full-text search also has good support for Chinese (there are many Chinese word segmenters alone), which can definitely meet the full-text search needs of most people in China.

In addition to searching, ES will automatically index all fields for you to achieve high-performance complex aggregation queries. Therefore, as long as the data is stored in ES, no matter how complex the aggregation query is, it can be Get good performance, and you no longer have to worry about how to build various complex indexes.

Redis

Redis is the most popular key-value database now. It was released in 2009 with MongoDB, and it is also a database masterpiece in the early big data era.

The biggest feature of Redis is of course the simplicity and high performance brought by key-value storage. (Recommended learning: Redis video tutorial)

The so-called key-value storage means that each record only contains a Key used to query data, and the corresponding value for storing data. Just like house numbers and residents in real life, there are no complex concepts such as tables and fields that are necessary in conventional databases. All queries only rely on key values.

Therefore, the key-value database can be said to be the simplest data structure in the database. It also benefits from this simple structure. In addition, Redis will load all data into memory. Redis can The read and write performance is much higher than that of conventional databases such as MongoDB.

Of course, the function of Redis is not just as simple as key-value storage. Compared with its key-value predecessor Memcached, Redis also supports data persistence, list, set and other data structures, master-slave replication and backup and a series of functions, so Redis can definitely be regarded as the most comprehensive and easiest-to-use model among key-value databases.

Redis’ key-value storage brings performance advantages, but it also brings many limitations to complex queries. Since important features such as data tables and fields are eliminated, and all queries rely on keys, Redis cannot provide complex query functions such as multi-column queries and section queries that conventional databases have. At the same time, because Redis needs to store data in memory, this also greatly limits the amount of data that Redis can store, which also determines that Redis is difficult to use in application scenarios with large data scales.

Difference

If you have extremely high requirements for reading and writing data, and your data is not large in size and does not require long-term storage, Choose redis;

If you need to construct a search engine or you want to build a high-end data visualization platform, and your data has certain analytical value or your boss is a rich man, choose ElasticSearch;

For more Redis-related technical articles, please visit the Redis database usage tutorial column to learn!

The above is the detailed content of The difference between elasticsearch and redis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn