当前位置:网站首页>Kibana operation es
Kibana operation es
2022-07-25 14:34:00 【You are like a sweet Yida】
List of articles
es On
es website
kibana operation es
Elaticsearch, Referred to as es, Yes es The operation is based on REST Style operation ;
The basic operations are :PUT( establish , modify ) POST( establish , modify ) DELETE( Delete ) GET( Inquire about ) POST( Inquire about ) ; We usually do the most additions, deletions, modifications and checks ; Query is the most important and complex .
What I posted can be copied directly to kibana Inside , Then you can create more data by yourself , You can make your own according to the query .
Simple operation
# obtain ElasticSearch A lot of current information !
GET _cat/
GET /_cat/plugins
## participle
GET _analyze
{
"analyzer": "ik_smart",
"text": " Young people don't speak martial arts "
}
GET _analyze
{
"analyzer": "ik_max_word",
"text": " Young people don't speak martial arts "
}
# Create index , Cannot modify after creation
PUT /test1
{
"mappings": {
"properties": {
"name":{
"type": "text"
},
"age":{
"type": "long"
},
"birthday":{
"type": "date"
},
"tag":{
"type": "text"
}
}
}
}
# Get index information
GET test1
## Delete index
DELETE test1
# The new document Appoint id, Follow random id
PUT /test1/_doc/1
{
"name":" Zhang Yida ",
"age":11,
"birthday": "1990-08-09"
}
POST /test1/_doc/
{
"name":" Zhang Yida ",
"age":11,
"birthday": "1990-08-09"
}
# Modify the document
# put Cover ,_version Meeting +1 If not, it will be empty ( Don't suggest , Fields will be lost , Unless you really want to cover it all )
PUT /test1/_doc/1
{
"name" : " Zhang Yida ",
"age" : 183
}
GET /test1/_doc/1
# post _update Suggest ,_version unchanged ( Suggest , Be careful doc Field )
POST /test1/_update/1/
{
"doc": {
"name" : " Zhang Yida 2"
}
}
GET /test1/_doc/1
Query operation
Query basic operations
## Inquire about
## Deprecation: [types removal] Specifying types in search requests is deprecated. Will let you delete type,_doc
GET /test1/_doc/_search?q=name: benefit
GET /test1/_search?q=name: benefit
GET /test1/_search?q=age:11
## Query match
##match: matching ( Can use word segmentation to parse ( First analyze the document , And then query ))
## term: Specify terms directly through inverted index , Accurate query , No participle , Suitable field types are number,date,keyword, Not suitable for text
##_source: Filter fields
##sort: Sort
##form、size Pagination
GET /test1/_search
{
"query": {
"match": {
"name": " Zhang "
}
}
,
"_source": ["name","age"],
"sort": [
{
"age": {
"order": "asc"
}
}
],
"from": 1
,
"size": 1
}
# Multiconditional query
#must amount to and
#should amount to or
#must_not amount to not (... and ...)
#filter Filter
GET /test1/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "1"
}
},
{
"match": {
"age": "1"
}
}
],
"filter": [
{
"range": {
"age": {
"gte": 1,
"lte": 2
}
}
}
]
}
}
}
# Create an index with an array , If the index does not exist, it will be created automatically
POST /test_arr/_doc
{
"name" : " Zhang Yida 2",
"age" : 18,
"birthday":"1990-09-08",
"tag":[" The lawyer "," Funny "," self-confidence "]
}
POST /test_arr/_doc
{
"name" : " Zhang Yida 3",
"age" : 18,
"birthday":"1990-09-08",
"tag":[" The lawyer " ," male "]
}
GET /test_arr/_doc/1
GET /test_arr/_search
{
"query": {
"match": {
"tag": " male t "
}
}
}
# match Can use word segmentation to parse ( First analyze the document , And then query )
GET /test_arr/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": " Zhang "
}
},
{
"match": {
"tag": " Male lawyers are funny, female confident people "
}
}
]
}
}
}
# term Accurate query
GET /test1/_search
{
"query": {
"term": {
"age": 1
}
}
}
text and keyword
- text:
Support participle , Full text search 、 Support ambiguity 、 Precise query , Aggregation is not supported , The sorting operation ;
text The maximum supported character length of type is unlimited , Suitable for large field storage ; - keyword:
No participle , Direct index 、 Support ambiguity 、 Support exact match , Support aggregation 、 The sorting operation .
keyword The maximum supported length of a type is ——32766 individual UTF-8 Type of characters , Can be set by ignore_above Specify self-contained character length , Data beyond a given length will not be indexed , Unable to get term Exact matching search results return .
## test keyword and text Whether word segmentation is supported
PUT /test
{
"mappings": {
"properties": {
"text":{
"type":"text"
},
"keyword":{
"type":"keyword"
}
}
}
}
PUT /test/_doc/1
{
"text":" test keyword and text Whether word segmentation is supported ",
"keyword":" test keyword and text Whether word segmentation is supported "
}
# text Support participle
# keyword Participle... Is not supported
# Find out
GET /test/_doc/_search
{
"query":{
"match":{
"text":" test "
}
}
}
## We can't find it
GET /test/_doc/_search
{
"query":{
"match":{
"keyword":" test "
}
}
}
# Word segmentation analysis
GET _analyze
{
"analyzer": "keyword",
"text": [" test liu"]
}
GET _analyze
{
"analyzer": "standard",
"text": [" test liu"]
}
GET _analyze
{
"analyzer":"ik_max_word",
"text": [" test liu"]
}
Highlight query
## Highlight query , The main thing is to add prefix and suffix to the content of the query
GET test1/_doc/_search
{
"query": {
"match": {
"name":" Zhang "
}
}
,
"highlight": {
"pre_tags": "<p class='key' style='color:red'>",
"post_tags": "</p>",
"fields": {
"name": {
}
}
}
}
thus kibana operation es Some common operations of , See the official documents for more details :
https://www.elastic.co/guide/cn/elasticsearch/guide/current/full-body-search.html
The next section uses java Code operation es
边栏推荐
猜你喜欢

Oka pass rights and interests analysis is the best choice to participate in okaleido ecological construction

GameFramework制作游戏(二)制作UI界面

51单片机学习笔记(2)

Digital Twins - cognition

SSH服务器拒绝了密码

苹果官网产品打折 买iPhone 13 Pro Max 可省600元

D2. picking carrots (hard version) (one question per day)

Idea error failed to determine a suitable driver class

MySQL table operation

Doris学习笔记之与其他系统集成
随机推荐
How to make a set of code fit all kinds of screens perfectly?
PS制作加载GIF图片教程
English语法_不定代词 - other / another
Educational codeforces round 132 (rated for Div. 2) C, d+ac automata
Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]
Throwing OutOfMemoryError “Could not allocate JNI Env“
Teach you how to apply for SSL certificate
sqli-labs Basic Challenges Less11-22
Awk from getting started to digging in (21) awk script debugging
Apple failed to synchronize on its mobile terminal, so it exited the login. As a result, it could not log in again
Pytorch training code writing skills, dataloader, Einstein logo
The supply chain collaborative management system, a new "engine" of digitalization in machinery manufacturing industry, helps enterprises' refined management to a new level
Realize a family security and environmental monitoring system (II)
~4.1 sword finger offer 05. replace spaces
基于redis的keys、scan删除ttl为-1的key
51单片机学习笔记(1)
gson与fastjson
Awk from entry to earth (24) extract the IP of the instruction network card
Numpy basic package for data analysis
awk从入门到入土(20)awk解析命令行参数