elasticsearch+kibana- apis

This article explains the operation using the kibana tool:

Arrangement kibana

Download and unzip kibana, find kibana.yml in the config folder in the root directory, modify the configuration as follows
Insert picture description here

  • ** So far (the current official latest version is 6.4), the official means: temporarily does not support connecting multiple es nodes, that is, only one address can be filled in the configuration file above. ** Another solution provided by the official website: https://www.elastic.co/guide/en/kibana/6.4/production.html#load-balancing
    roughly means:

Build an es node that is only used for "coordination", let this node join the es cluster, and then kibana connects to this "coordination" node. This "coordination" node does not participate in the election of the master node and does not store data. Incoming HTTP request, and redirect the operation to other es nodes in the cluster, then collect and return the result. This "coordination" node also essentially plays a role of load balancing.

After installing the xpack plugin, you can enable login verification. If the password is configured as follows:
Insert picture description here
you can start it after the configuration is complete, visit: http: // localhost: 5601

basic concept

_index    文档在哪存放
_type     文档表示的对象类别
_id         文档唯一标识

Index API

# 创建索引(插入数据,没有索引会创建)
PUT twitter/_doc/1
{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}

Insert picture description here
total-Indicates that the index operation should be performed on multiple shard copies (primary shard and replica shard).
successful-Indicates the number of shard copies successfully performed by the index operation.
failed-If the index operation fails on the replica fragment, the array containing errors related to replication

# 允许创建 叫twitter,index10 没有其他的折射率匹配index1*,以及任何其他折射率匹配ind*。模式按照给定的顺序进行匹配
PUT _cluster/settings
{
    "persistent": {
        "action.auto_create_index": "twitter,index10,-index1*,+ind*" 
    }
}
# 不允许 自动创建索引
PUT _cluster/settings
{
    "persistent": {
        "action.auto_create_index": "false" 
    }
}
# 允许创建所有类型索引
PUT _cluster/settings
{
    "persistent": {
        "action.auto_create_index": "true" 
    }
}

Get API

# 根据id查询
GET twitter/_doc/1

Insert picture description here

Delete API

# 根据id删除
DELETE /twitter/_doc/1
# 根据查询条件删除
POST twitter/_delete_by_query
{
  "query": { 
    "match": {
      "user": "kimchy"
    }
  }
}

Insert picture description here

Bulk API

#多条命令一起执行
POST _bulk
{ "index" : { "_index" : "test", "_type" : "_doc", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "_doc", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "_doc", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "_doc", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }

API update

POST twitter/_doc/3/_update
{
    "doc" : {
        "user" : "liuli-new"
    }
}

Insert picture description here

Reindex API

POST _reindex
{
  "source": {
    "index": "twitter"
  },
  "dest": {
    "index": "new_twitter"
  }
}

This article is simply a few examples, many es api documentation, refer to the official documentation to learn according to their needs
Insert picture description here
reference documentation:
https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docs.html

Published 51 original articles · won praise 2 · Views 6374

Guess you like

Origin blog.csdn.net/wenwang3000/article/details/100089770