当前位置:网站首页>Elasitcsearch basic learning notes (1)
Elasitcsearch basic learning notes (1)
2022-06-11 16:40:00 【chenxiky】
One . Basic concepts
Classification of data
1. Structured data : Having a fixed or limited format ⻓ Degree data , Such as a database , Metadata, etc . For structured data , We ⼀ Generally, you can use relational database (mysql,oracle etc. ) Of table Of ⽅ Storage and search , You can also build ⽴ Indexes . adopt b-tree And other data structures to quickly search data .
2.⾮ Structured data : whole ⽂ data , I don't know ⻓ or ⽆ Fixed format data , Like email ,word⽂ Gear, etc . about ⾮ Structured data , That is, to all ⽂ There are two main types of data search ⽅ Law : Sequential scanning , whole ⽂ Search .
whole ⽂ Search for
Yes ⾮ Information is extracted from structured data , Reorganize , Make it ⼀ Structure , And then there are ⼀ Structured data entry ⾏ Search for , from ⽽ Achieve a relatively fast search ⽬ Of . this Kind of ⽅ The formula constitutes the whole ⽂ The basic idea of search . This part starts from ⾮ A letter extracted from structured data and then reorganized Rest , We call it index .
What is all ⽂ Search engine ?
⼯ How it works : It's a computer cable Introduce the program through scanning ⽂ Every... In the chapter ⼀ Word , For each ⼀ Geci Jian ⽴⼀ An index , Indicate that the word is in ⽂ The number of occurrences and bits in the chapter Set up , When ⽤ When the user inquires , The search program is built in advance ⽴ The introduction of ⾏ lookup , And feed back the search results to ⽤ Household .
The main search engines are :Lucene 、Solr 、Elastic search.
Suitable for all ⽂ The scenario of the index engine
The data objects searched are ⼤ Quantitative ⾮ A structured ⽂ This data .
⽂ The amount of this data reaches ⼗ Tens of thousands or millions , what ⾄ more .
⽀ a ⼤ Volume is based on interactive ⽂ This query . demand ⾮ Always flexible ⽂ Search for .
For security affairs ,⾮⽂ The demand for this data operation is relatively small .
Elasticsearch Elasticsearch yes ⼀ Open source , yes ⼀ Based on Apache Lucene Library built Restful Search engine .
The main function : Distributed search Data analysis Group and aggregate
Should be ⽤ scene : Wikipedia Stack Overflow GitHub Online retailers ⽹ standing ⽇ Log data analysis Commodity price monitoring ⽹ standing BI System On-site search Basketball Forum
Two .Elasticsearch Introduction to the basic catalogue and its general structure

Indexes (index):⼀ An index can be understood as ⼀ A relational database .
type (type): ⼀ Kind of type It's like ⼀ Class table ,⽐ Such as user surface ,order surface . Be careful : ES 5.x in ⼀ individual index There can be many type. ES 6.x in ⼀ individual index There can only be ⼀ Kind of type. ES 7.x Has been removed since type The concept .
mapping (mapping) :mapping Defines the type of each field and other information . It is equivalent to the table structure in relational database . ⽂ files (document) ⼀ individual document Equivalent to... In a relational database ⼀⾏ Record .
Field (field) : It is equivalent to the fields of relational database tables colony (cluster) Clusters are composed of ⼀ One or more nodes ,⼀ Clusters have ⼀ Default names "elasticsearch".
node (node) : Cluster node ,⼀ A machine or ⼀ A process .
branch ⽚ And copies (shard) : The copy is divided into ⽚ Copy of . branch ⽚ There are principal components ⽚(primary Shard) And copies ⽚(replica Shard) Points . ⼀ individual Index Data is physically distributed across multiple primary partitions ⽚ in , Each main branch ⽚ Only part of the data is stored . Each main branch ⽚ There can be multiple copies , Let's divide the copies ⽚, It is the main part ⽚ Copy .
elasticsearch send ⽤RESTful⻛ grid api To design the :RESTful yes ⼀ Specifications and constraints of the architecture 、 principle , The architecture that fits this specification is RESTful framework .

3、 ... and .ES Basic use
1. The introduction of the index and its application ⽤
Add index :PUT "localhost:9200/nba"
Get index :GET "localhost:9200/nba"
Delete index :DELETE "localhost:9200/nba"
Get index in batch :GET "localhost:9200/nba,cba"
Get all indexes :GET "localhost:9200/_all" GET "localhost:9200/_cat/indices?v"
2. Introduction and implementation of mapping ⽤
New mapping PUT "localhost:9200/nba/_mapping"
{ "properties": { "name": { "type": "text" }, "team_name": { "type": "text" }, "position": { "type": "keyword" }, "play_year": { "type": "keyword" }, "jerse_no": { "type": "keyword" Respond to obtain request Respond to Batch acquisition request } } }Acquisition mapping GET "localhost:9200/xdclass/_mapping"
Batch acquisition :GET "localhost:9200/nba,cba/mapping"
Get all :1.X GET "localhost:9200/_mapping";2.GET "localhost:9200/_all/_mapping"
Modify mapping :PUT "localhost:9200/nba/_mapping"
{
"properties": {
"name": {
"type": "text"
},
"team_name": {
"type": "text"
},
"position": {
"type": "keyword"
},
"play_year": {
"type": "keyword"
},
"jerse_no": {
"type": "keyword"
},
"country": {
"type": "keyword"
}
}
}3.⽂ Addition, deletion and modification of files
newly added ⽂ files :1.PUT localhost:9200/nba/_doc/1 ( Appoint id) notes : Specify the need for PUT
2.POST localhost:9200/nba/_doc ( Don't specify id) You don't have to specify
{ "name":" library ⾥", "team_name":" yong ⼠", "position":" Organizing guards ", "play_year":"10", "jerse_no":"30" }
see ⽂ files :GET localhost:9200/nba/_doc/1
View multiple ⽂ files :1.POST localhost:9200/_mget
{"docs" : [ { "_index" : "nba", "_type" : "_doc", "_id" : "1" }, { "_index" : "nba", "_type" : "_doc", "_id" : "2" } ] }
2.POST localhost:9200/nba/doc/mget
{ "docs" : [ { "_id" : "1" }, { "_id" : "2" } ] }
3.GET localhost:9200/nba/doc/mget
{ "ids" : ["1", "2"] }
modify ⽂ files : POST localhost:9200/nba/_update/1
{ "doc": { "name": " harden ", "team_name": "⽕ arrow ", "position": " Double energy guard ", "play_year": "10", "jerse_no": "13" } }
towards _source Field , increase ⼀ A field :POST localhost:9200/nba/_update/1
{ "script": "ctx._source.age = 18" }
from _source Field , Delete ⼀ A field :POST localhost:9200/nba/_update/1
{ "script": "ctx._source.remove(\"age\")" }
According to the parameter value , Updates the specified ⽂ File fields :POST localhost:9200/nba/_update/1
{ "script": { "source": "ctx._source.age += params.age", "params": { "age": 4 } } }
upsert When the specified ⽂ When the gear does not exist ,upsert The content contained in the parameter will be inserted ⼊ Into the index , As ⼀ individual new ⽂ files ; If specified ⽂ The file does not exist ,ElasticSearch The engine will run ⾏ Specified update logic .
POST localhost:9200/nba/_update/3
{ "script": { "source": "ctx._source.allstar += params.allstar", "params": { "allstar": 4 } }, "upsert": { "allstar": 1 } }
Delete ⽂ files :DELETE localhost:9200/nba/_doc/1
To be continued ......
边栏推荐
- ^31原型面试题
- LeetCode——24. 两两交换链表中的节点(三指针)
- 美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战
- 数据库备份(Mysql)
- leetcode-141.环形链表
- 2022年R1快开门式压力容器操作考试题库及模拟考试
- leetcode417. Pacific Atlantic current problems (medium)
- pycharm和anaconda的基础上解决Jupyter连接不上Kernel(内核)的问题--解决方案1
- Analysis report on the "fourteenth five year plan" proposal and innovation environment of global and Chinese sodium pyrophosphate industry (2022-2028)
- Elasitcsearch基础学习笔记(1)
猜你喜欢

2022 safety officer-a certificate test question simulation test question bank simulation test platform operation

Differences between list and set access elements

leetcode417. 太平洋大西洋水流问题(中等)

时间复杂度与空间复杂度解析

微服务连接云端Sentinel 控制台失败及连接成功后出现链路空白问题(已解决)

20 full knowledge maps of HD data analysis have been completed. It is strongly recommended to collect them!

Global and Chinese molten carbonate fuel cell industry outlook and market panoramic Research Report 2022-2028
![[sword finger offer] 22 The penultimate node in the linked list](/img/66/630ae9762f9d87817a14cb1c96015b.png)
[sword finger offer] 22 The penultimate node in the linked list

C starts an external EXE file and passes in parameters

Web page design example assignment -- Introduction to Henan cuisine (4 pages) web final assignment design web page_ Dessert and gourmet college students' web design homework finished product
随机推荐
Rdkit installation
Weekly recommended short video: rookie CEO talks about the new logistics track in the future
Solve the problem that jupyter cannot connect to the kernel based on pycharm and Anaconda -- solution 1
select into from 和 insert into select 区别
leetcode785. 判断二分图(中等)
(验证文件)validateJarFile...报错
Search and graph theory: Dijkstra finding the shortest path i-dijkstra (shortest path)
2022年危险化学品经营单位主要负责人考试模拟100题及模拟考试
项目经理如何击退被工作汇报支配的恐惧感?
2022g1 industrial boiler stoker test questions and simulation test
[从零开始学习FPGA编程-17]:快速入门篇 - 操作步骤2-5- VerilogHDL硬件描述语言符号系统与程序框架(软件程序员和硬件工程师都能看懂)
Enterprise purchase, sales and inventory management system based on SSM framework [source code + database + design]
基于ssm框架实现的企业进销存管理系统【源码+数据库+毕设】
Oracle数据库合并行记录,WMSYS.WM_CONCAT 函数的用和MySQL 中GROUP_CONCAT(id)的使用及比较。
tornado环境搭建及基本框架搭建——熟悉的hello world
JDBC debugging error, ask for guidance
Elasitcsearch基础学习笔记(1)
学生网站模板棕色蛋糕甜品网站设计——棕色蛋糕甜品店(4页) 美食甜品网页制作期末大作业成品_生鲜水果网页设计期末作业
Global and Chinese molten carbonate fuel cell industry outlook and market panoramic Research Report 2022-2028
A team of heavyweights came to the "digital transformation" arena of CLP Jinxin ice and snow sports