当前位置:网站首页>Kibana index, mapping, document operation

Kibana index, mapping, document operation

2022-07-05 00:23:00 Dalon_ G

This article needs to be configured elasticsearch and kibana Post consumption , See   Portal

Catalog

1. Operation of index

2. Mapping operations

3. Document operation and partial update


1. Operation of index

# Index related 
# Create index 
PUT /test
# Determine if the index exists 
HEAD /test
# Look at the index 
GET /test
# View all indexes 
GET _all
# Look at the index , And you can see health information and other attributes 
GET /_cat/indices?v
# Close index 
POST /test/_close
# Look at the index again ( Mainly depends on the state )
GET /_cat/indices?v
# Open the index 
POST /test/_open
# Delete index 
DELETE /test
# Judge whether it exists 
HEAD /test


2. Mapping operations

# Mapping correlation 
# Create mapping fields   grammar 
PUT / Index name /_mapping
{
  "properties":{
    " Field name ":{
      "type":" type ",
      "index":"true", 
      "store":"true",
      "analyzer":" Word segmentation is "
    }
  }
}

# Create a mapping field case 

PUT /test/_mapping
{
  "properties":{
    "name":{
      "type":"text",
      "analyzer":"ik_max_word"
    },
    "job":{
      "type":"text",
      "analyzer":"ik_max_word"
    },
    "logo":{
      "type":"keyword",
      "index":false
    }
  }
}
# View mapping relationships 
GET /test/_mapping
GET _mapping
GET _all/_mapping
# Modify mapping relationship 
# You can only add mappings , If other operations need to be deleted, add again 
PUT /test/_mapping
{
  "properties":{
    "age":{
      "type":"integer",
      "index":false
    }
  }
}
# Create indexes and maps at once 
PUT /test2
{
  "settings": {}
  , "mappings": {
    "properties":{
    "name":{
      "type":"text",
      "analyzer":"ik_max_word"
    },
    "job":{
      "type":"text",
      "analyzer":"ik_max_word"
    },
    "logo":{
      "type":"keyword",
      "index":false
    }
  }
  }
}
# View the map 
GET /test2/_mapping

3. Document operation and partial update

# New document 
POST /test/_doc/1
{
  "name":" Zhang San ",
  "age":22
}
# To view the document 
GET /test/_doc/1
# View all the documents 
GET /test/_search
{
  "query": {
    "match_all": {}
  }
}
# Custom return results    Appoint source Return results 
GET /test/_doc/1?_source=name,age
# to update    Full update ( Just put the created post Change it to put)
# Note here , If the original attribute value has , There is no new one , Some attributes will be deleted 
# If specified id There is , Then update , If it doesn't exist , Then create 
PUT /test/_doc/1
{
  "name":" Li Si "
}
# see    Only name 了 
GET /test/_doc/1
# Partial update 
POST /test/_update/1
{
  "doc": {
    "age":22
  }
}

# see   Added age
GET /test/_doc/1
# Delete 
DELETE /test/_doc/1

# see   "found" : false
GET /test/_doc/1

# Conditions delete 
# Create a new document again 
POST /test/_doc/1
{
  "name":" Zhang San ",
  "age":22
}
POST /test/_doc/2
{
  "name":" Li Si ",
  "age":25
}
POST /test/_delete_by_query
{
  "query":{
    "match":{
      "name":" Zhang San "
    }
  }
}
# View all the documents   , also name For Li Si 
# Delete all 
POST /test/_delete_by_query
{
  "query":{
    "match_all":{
    }
  }
}
# See all again , Then all are deleted 
GET /test/_search
{
  "query": {
    "match_all": {}
  }
}
# Force creation , If id There is , Error report in execution   "status" : 409
PUT /test/_doc/1/_create
{}

原网站

版权声明
本文为[Dalon_ G]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141126362749.html