当前位置:网站首页>Kibana controls es
Kibana controls es
2022-07-02 02:14:00 【CV Engineer】
1. Operation of index
The index is equivalent to mysql In the table
Mapping is equivalent to mysql The specified field type in
The index cannot be modified
# see es Middle index
GET /_cat/indices
# see es Index and title in
GET /_cat/indices?v
# Create index
PUT /products
# Create index 、 Specified mapping
PUT /products
{
"mappings": {
"properties": {
"id":{
"type": "integer"
},
"title":{
"type": "keyword"
}
}
}
}
# View the map
GET /products/_mapping
# Delete index
DELETE /products
2. Addition, deletion, modification and query of documents
The document is equivalent to mysql One of the records
# Add the document Specify manually id
POST /products/_doc/1
{
"id":1,
"title":" Raccoon "
}
# Add the document Automatically create id
POST /products/_doc/
{
"title":" Lesser panda "
}
# Query the document
GET /products/_doc/1
# Delete the document
DELETE /products/_doc/1
# Update the document Will delete the original document , Add it again
PUT /products/_doc/1
{
"title":" Little raccoon "
}
# Update the document Update based on the specified field
POST /products/_doc/1/_update
{
"doc":{
"title":" Little raccoon "
}
}
3. Batch operation of documents
For batch operation data, you cannot wrap lines , Otherwise, an error will be reported
# Add documents in batch
POST /products/_doc/_bulk
{"index":{"_id":2}}
{"id":2,"title":" tencent "}
{"index":{"_id":3}}
{"id":3,"title":" MIHA Tour "}
# Batch addition 、 to update 、 Delete the document
POST /products/_doc/_bulk
{"index":{"_id":4}}
{"id":4,"title":" Sweet but not spicy "}
{"update":{"_id":3}}
{"doc":{"title":" Ali "}}
{"delete":{"_id":2}}
4. Advanced query of documents
# Query all
GET /products/_search
{
"query":{
"match_all":{}
}
}
#term Query based on keywords
# stay ES Chinese word segmentation , English word segmentation
# stay ES In addition to text Type participle , The other types are not word segmentation
GET /products/_search
{
"query":{
"term":{
"title":" Ali "
}
}
}
# Range queries
GET /products/_search
{
"query": {
"range": {
"price": {
"gte": 10, // there gte Represents greater than or equal to ,gt Is greater than
"lte": 20 // lte Represents less than or equal to ,lt Is less than
}
}
}
}
# Prefix query
GET /products/_search
{
"query":{
"prefix":{
"title":{
"value": " Small "
}
}
}
}
#wildcard Wildcard query ? Match a character * Match multiple characters
GET /products/_search
{
"query":{
"wildcard":{
"title":{
"value": " Small ?"
}
}
}
}
# according to id Group query
GET /products/_search
{
"query":{
"ids":{
"values": [1,3,4]
}
}
}
# Fuzzy query , Not equal to mysql Fuzzy query of , Baidu
GET /products/_search
{
"query":{
"fuzzy":{
"title":" Little raccoon "
}
}
}
# Boolean query
#must: Must match each subquery , similar “ And ”
#should: Selective matching sub query , similar “ or ”
#must_not: Must not match , Do not participate in the calculation of points , similar “ Not ”
#filter: Must match , Do not participate in the calculation of points
GET /hotel/_search
{
"query": {
"bool": {
"must": [
{"term": {"city": " Shanghai " }}
],
"should": [
{"term": {"brand": " Crowne Plaza " }},
{"term": {"brand": " RAMADA " }}
],
"must_not": [
{ "range": { "price": { "lte": 500 } }}
],
"filter": [
{ "range": {"score": { "gte": 45 } }}
]
}
}
}
# Query in multiple fields , Will segment keywords and then search
GET /products/_search
{
"query":{
"multi_match":{
"query":" Raccoon cat ",
"fields": ["title","description"]
}
}
}
# The highlighted
# Highlight is to highlight keywords , Therefore, the search criteria must contain keywords , It can't be a query such as a range .
# By default , Highlighted fields , Must be consistent with the fields specified in the search , Otherwise, it can't be highlighted
# If you want to highlight a non search field , You need to add an attribute :required_field_match=false
GET /hotel/_search
{
"query": {
"match": {
"FIELD": "TEXT" // Query criteria , Be sure to use full-text search queries
}
},
"highlight": {
"fields": { // Specify the field to highlight
"FIELD": {
"pre_tags": "<em>", // The leading label used to mark the highlighted field
"post_tags": "</em>" // The post label used to mark the highlighted field
}
}
}
}
# Paging and ascending
GET /hotel/_search
{
"query": {
"match_all": {}
},
"from": 0, // Where paging begins , The default is 0
"size": 10, // Total number of documents expected to get
"sort": [
{"price": "asc"}
]
}
5. Filtering and querying documents
Filtering queries will not calculate data scores , The previous queries in Section 5 are documents query Inquire about , This will calculate the data score , Affect query performance . stay ES First, filter and query , Document again query Inquire about .
GET /hotel/_search
{
"query": {
"bool": {
"must": [
{"term": {"city": " Shanghai " }}
],
"should": [
{"term": {"brand": " Crowne Plaza " }},
{"term": {"brand": " RAMADA " }}
],
"must_not": [
{ "range": { "price": { "lte": 500 } }}
],
"filter": [
{ "range": {"score": { "gte": 45 } }}
]
}
}
}
边栏推荐
- JS slow animation
- Infix expression to suffix expression (computer) code
- Design and implementation of key value storage engine based on LSM tree
- MySQL如何解决delete大量数据后空间不释放的问题
- AR增强现实可应用的场景
- How to use a product to promote "brand thrill"?
- 软件开发生命周期 --瀑布模型
- Bash bounce shell encoding
- leetcode2305. 公平分发饼干(中等,周赛,状压dp)
- CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
猜你喜欢
No programming code technology! Four step easy flower store applet
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
What is the MySQL column to row function
Summary of some experiences in the process of R & D platform splitting
Deployment practice and problem solving of dash application development environment based on jupyter Lab
734. Energy stone (greed, backpack)
How to batch add background and transition effects to videos?
医药管理系统(大一下C语言课设)
Comparative analysis of MVC, MVP and MVVM, source code analysis
【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)
随机推荐
Ar Augmented Reality applicable scenarios
Is the knowledge of University useless and outdated?
Cesium dynamic diffusion point effect
How to execute an SQL in MySQL
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
Deployment practice and problem solving of dash application development environment based on jupyter Lab
leetcode2310. The one digit number is the sum of integers of K (medium, weekly)
【带你学c带你飞】day 5 第2章 用C语言编写程序(习题2)
Exception handling of class C in yyds dry goods inventory
AR增强现实可应用的场景
Quality means doing it right when no one is looking
Opengauss database backup and recovery guide
【OpenCV】-5种图像滤波的综合示例
Bash bounce shell encoding
剑指 Offer 29. 顺时针打印矩阵
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
【带你学c带你飞】2day 第8章 指针(练习8.1 密码开锁)
Pat a-1165 block reversing (25 points)
Deep learning: a solution to over fitting in deep neural networks