编程知识 cdmana.com

Detailed explanation of elasticsearch's usage scenarios

I understand ES Usage scenarios of ,ES The study of 、 Use 、 Promotion is more valuable and meaningful .

1、 scene —: Use Elasticsearch As the main back end

In traditional projects , Search engines are deployed on top of mature data stores , To provide fast and relevant search capabilities . This is because early search engines can't provide durable ​​ Storage or other frequently needed functions , Such as statistics .
 Picture description here
Elasticsearch Is to provide persistent storage 、 Statistics and other functions of modern search engine .
If you start a new project , We suggest that you consider using Elasticsearch As the only data store , To help keep your design as simple as possible .
This scenario does not support frequent updates 、 Business (transaction) The operation of .

Examples are as follows : Create a new blog system to use es As the storage .
1) We can approach ES Submit a new blog post ;
2) Use ES retrieval 、 Search for 、 statistics .

ES As a storage advantage :
What happens if a server fails ? You can copy Data is sent to different servers for fault tolerance .
Be careful :
When designing the overall architecture , We need to weigh the need for additional storage .

2、 Scene two : Add... To the existing system elasticsearch

because ES Not all the features of storage are available , In some scenarios, it is necessary to add new data to the existing system data storage ES Support .
 Picture description here
give an example 1:ES Unsupported transaction 、 A complex relationship ( At least 1.X Version not supported ,2.X There has been improvement , But the support is still not good ), If you need the support of the above features in your system , Need to consider in the original architecture 、 New addition based on original storage ES Support for .

give an example 2: If you already have a complex system running , One of your requirements is to add search services to the existing system . One very risky way is to refactor the system to support ES. And the relatively safe way is : take ES Add as a new component to an existing system .
If you use the one shown below SQL Database and ES Storage , You need to find a way to synchronize the two stores in real time . According to the composition of the data 、 The database selects the corresponding synchronization plug-in . Plug in options include :
1)mysql、oracle choice logstash-input-jdbc plug-in unit .
2)mongo choice mongo-connector Tools .

Suppose the product information of your online retail store is stored in SQL In the database . For fast and relevant searches , You install Elasticsearch.
To index data , You need to deploy a synchronization mechanism , The synchronization mechanism can be Elasticsearch Plug in or you create a custom service . This synchronization mechanism can store all the data and indexes corresponding to each product in Elasticsearch, Each product as a document Storage ( there document Equivalent to a row in a relational database /row data ).

When you enter “ Types of users ”, The storefront web application goes through Elasticsearch Query this information . Elasticsearch Return products that meet the standard documents, And sort the documents according to the way you like . Ranking can be based on the number of times each product is searched , Or anything stored in the product document Information , for example : The latest recently added product 、 Average score , Or insert or update information . So you can just use Elasticsearch Processing search . It depends on the synchronization mechanism to keep Elasticsearch Get the latest changes .

3、 Scene three : Use elasticsearch And existing tools

In some cases , You don't have to write a single line of code to get through elasticssearch Finish a job . Many tools can be used with Elasticsearch Working together , So you don't have to write from scratch .
for example , Suppose you want to deploy a large-scale log framework storage , Search for , And analyzed a lot of events .
As shown in the figure below , Process logs and output to Elasticsearch, You can use the logging tool , Such as rsyslog(www.rsyslog.com),Logstash(www.elastic.co/products/logstash), or Apache Flume(http://flume.apache.org).
Search and visual interface to analyze these logs , You can use Kibana(www.elastic.co/ product / kibana).
 Picture description here

Why so many tools fit Elasticsearch? The main reasons are as follows :

1)Elasticsearch It's open source. .
2)Elasticsearch Provides JAVA API Interface .
3)Elasticsearch Provides RESTful API Interface ( No matter what language the program is developed in , Any program can access )
4) what's more ,REST Requests and responses are typical JSON(JavaScript object Symbol ) Format . Usually , One REST The request contains a JSON file , The responses are Also a JSON file .

——————————————————————————————————
more ES Experience sharing of dry goods in actual combat , Please scan below 【 Mingyi world 】 WeChat official account for two-dimensional code .
( Update at least one article per week !)

 Picture description here
Be with you , screwing Elasticsearch
——————————————————————————————————

author : Mingyi world
Reprint please indicate the source , Original address :
http://blog.csdn.net/laoyang360/article/details/52227541
If you feel this article is helpful , Please click on ‘ The top ’ support , Your support is my biggest motivation for writing , thank you !

版权声明
本文为[Mingyi world]所创,转载请带上原文链接,感谢

Scroll to Top