Elasticsearch (1) First acquaintance with Elasticsearch

What is search?
Baidu: For example, when we want to find any information, we will go to Baidu to search, such as a movie we like, or a book we like, or a piece of news that we are interested in (mentioned). search first impression)
Baidu != search, this is wrong

Vertical search (in-site search)
Internet search: e-commerce websites, recruitment websites, news websites, various apps
Search of IT systems: OA software, office automation software, meeting management, schedule management, project management, employee management, search for "Zhang San", "Zhang San'er", "Zhang Xiaosan"; there is an e-commerce website, seller, background Management system, search for "toothpaste", orders, "toothpaste related orders"

Search is to find the information you want in any scenario. At this time, you will enter a keyword you want to search for, and then expect to find some information related to this keyword.

What if the database is used for searching?

If you do software development, or if you have a certain understanding of IT and computers, you all know that data is stored in the database, such as commodity information on e-commerce websites, job information on recruitment websites, news information on news websites, etc. wait. Therefore, it is natural that if we consider from the technical point of view, how to realize the search function inside the e-commerce website, for example, we can consider using the database to search.

1. For example, the text of the specified field of each record may be very long. For example, the length of the "Product Description" field can be as long as thousands or even tens of thousands of characters. Scan all the text of each record, and the lazy judgment says that your package does not contain the keyword I specified (for example, "toothpaste")
2. You can't separate the search words, try to search for more results that meet your expectations, for example, if you enter "biochemical machine", you will not be able to search for "biochemical crisis"

It is not very reliable to use the database to realize the search. In general, performance will be poor.


What is Full Text Search and Lucene?

(1) Full-text search, inverted index
(2)lucene,就是一个jar包,里面包含了封装好的各种建立倒排索引,以及进行搜索的代码,包括各种算法。我们就用java开发的时候,引入lucene jar,然后基于lucene的api进行去进行开发就可以了。用lucene,我们就可以去将已有的数据建立索引,lucene会在本地磁盘上面,给我们组织索引的数据结构。另外的话,我们也可以用lucene提供的一些功能和api来针对磁盘上额

什么是Elasticsearch?




Elasticsearch的功能

(1)分布式的搜索引擎和数据分析引擎

搜索:百度,网站的站内搜索,IT系统的检索
数据分析:电商网站,最近7天牙膏这种商品销量排名前10的商家有哪些;新闻网站,最近1个月访问量排名前3的新闻版块是哪些
分布式,搜索,数据分析

(2)全文检索,结构化检索,数据分析

全文检索:我想搜索商品名称包含牙膏的商品,select * from products where product_name like "%牙膏%"
结构化检索:我想搜索商品分类为日化用品的商品都有哪些,select * from products where category_id='日化用品'
部分匹配、自动完成、搜索纠错、搜索推荐
数据分析:我们分析每一个商品分类下有多少个商品,select category_id,count(*) from products group by category_id

(3)对海量数据进行近实时的处理

分布式:ES自动可以将海量数据分散到多台服务器上去存储和检索
海联数据的处理:分布式以后,就可以采用大量的服务器去存储和检索数据,自然而然就可以实现海量数据的处理了
近实时:检索个数据要花费1小时(这就不要近实时,离线批处理,batch-processing);在秒级别对数据进行搜索和分析

跟分布式/海量数据相反的:lucene,单机应用,只能在单台服务器上使用,最多只能处理单台服务器可以处理的数据量

Elasticsearch的适用场景

国外

(1)维基百科,类似百度百科,牙膏,牙膏的维基百科,全文检索,高亮,搜索推荐
(2)The Guardian(国外新闻网站),类似搜狐新闻,用户行为日志(点击,浏览,收藏,评论)+社交网络数据(对某某新闻的相关看法),数据分析,给到每篇新闻文章的作者,让他知道他的文章的公众反馈(好,坏,热门,垃圾,鄙视,崇拜)
(3)Stack Overflow(国外的程序异常讨论论坛),IT问题,程序的报错,提交上去,有人会跟你讨论和回答,全文检索,搜索相关问题和答案,程序报错了,就会将报错信息粘贴到里面去,搜索有没有对应的答案
(4)GitHub(开源代码管理),搜索上千亿行代码
(5)电商网站,检索商品
(6)日志数据分析,logstash采集日志,ES进行复杂的数据分析(ELK技术,elasticsearch+logstash+kibana)
(7)商品价格监控网站,用户设定某商品的价格阈值,当低于该阈值的时候,发送通知消息给用户,比如说订阅牙膏的监控,如果高露洁牙膏的家庭套装低于50块钱,就通知我,我就去买
(8)BI系统,商业智能,Business Intelligence。比如说有个大型商场集团,BI,分析一下某某区域最近3年的用户消费金额的趋势以及用户群体的组成构成,产出相关的数张报表,**区,最近3年,每年消费金额呈现100%的增长,而且用户群体85%是高级白领,开一个新商场。ES执行数据分析和挖掘,Kibana进行数据可视化

国内

(9)国内:站内搜索(电商,招聘,门户,等等),IT系统搜索(OA,CRM,ERP,等等),数据分析(ES热门的一个使用场景)

Elasticsearch的特点

(1)可以作为一个大型分布式集群(数百台服务器)技术,处理PB级数据,服务大公司;也可以运行在单机上,服务小公司
(2)Elasticsearch不是什么新技术,主要是将全文检索、数据分析以及分布式技术,合并在了一起,才形成了独一无二的ES;lucene(全文检索),商用的数据分析软件(也是有的),分布式数据库(mycat)
(3)对用户而言,是开箱即用的,非常简单,作为中小型的应用,直接3分钟部署一下ES,就可以作为生产环境的系统来使用了,数据量不大,操作不是太复杂
(4)数据库的功能面对很多领域是不够用的(事务,还有各种联机事务型的操作);特殊的功能,比如全文检索,同义词处理,相关度排名,复杂数据分析,海量数据的近实时处理;Elasticsearch作为传统数据库的一个补充,提供了数据库所不不能提供的很多功能


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324699224&siteId=291194637