ES API,使用Kibana的开发工具用例说明

导读:本篇文章讲解 ES API,使用Kibana的开发工具用例说明,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

创建template,用于滚动索引

PUT _template/test-logs
{
  "index_patterns": "test-logs-*",
  "settings": {
		"number_of_shards": 5,
		"number_of_replicas": 1,
		"analysis": {
      "analyzer": {
        "my_analyzer": {
          "type": "pattern",
          "pattern":["_","-"]
        }
      }
    }
	},
	"aliases": {
    "test-logs-read": {}
  },
  "mappings": {
    "_doc":{
      "properties": {
				"file_name": {
					"type": "text"
				},
				"table": {
				  "type": "text",
					"analyzer": "my_analyzer"
				},
				"size": {
					"type": "text",
					"index": false
				}
			}
    }
  }
}

判断template是否存在

HEAD _template/test-logs

测试自定义解析器

POST my_index1/_analyze
{
  "analyzer": "my_analyzer",
  "text": "103_addserialnumber-1"
}

测试内置解析器

GET _analyze
{
  "analyzer": "ik_smart", 
  "text": "五常大米"
}

查index信息

GET /test-logs-100000

添加document

POST /test-logs-write/_doc
{
  "name":"mao",
  "sex" :"Male"
}

查index下document全部信息

GET /test-logs-read/_search
{
   "query": {
        "match_all": {}
    },
    "from":0,
    "size": 10
}

查所有template

GET  _cat/templates/

删除index

DELETE /test-logs-write

查某一template信息

GET _template/test-logs

模糊搜索+高亮显示

GET 12_assets_directory_v1/_doc/_search
{
    "query": {
        "multi_match":{
            "query": "月份",
            "fields": ["file_name","database_name","table_name"]                  
        }
    },
    "highlight": {
        "fields": {
            "file_name":{
                 "pre_tags": "<font color=red>",
                "post_tags": "</font>"
            },"database_name":{
                 "pre_tags": "<font color=red>",
                "post_tags": "</font>"
            },"table_name":{
                 "pre_tags": "<font color=red>",
                "post_tags": "</font>"
            }
        }
    },
    "sort": [
      {"_score": {"order": "desc"}},
      {"_doc": {"order": "desc"}}
    ],
    "from":0,
    "size": 2
}

设置滚动索引

OST index_alias_name/_rollover/
    {
      "conditions": {
        "max_age": "7d", //设置:最大时间7天
        "max_docs": 10000,//设置:最大文档记录数
        "max_size":  "5gb" //设置:索引最大容量
      }
    }

批量插入

POST _bulk/?refresh=true
{ "index" : { "_index" : "12_assets_directory_v1","_type" : "_doc" }}
{ "file_name": "Lucene is cool","file_type": "file","database_name": "","table_name": "","include_fields": "","source_business": 1,"store_type": "hdfs","whether_online": 0,"foreign_id": 10,"update_time": 1618560193000}
{ "index" : { "_index" : "12_assets_directory_v1","_type" : "_doc" }}
{ "file_name": "hdfs用户文件","file_type": "file","database_name": "","table_name": "","include_fields": "","source_business": 1,"store_type": "hdfs","whether_online": 0,"foreign_id": 11,"update_time": 1618560193010}
{ "index" : { "_index" : "12_assets_directory_v1","_type" : "_doc" }}
{ "file_name": "","file_type": "table","database_name": "geespace_bd_platform_dev","table_name": "12_mysql-1","include_fields": "","source_business": 1,"store_type": "mysql","whether_online": 0,"foreign_id": 10,"update_time": 1618560193020}
{ "index" : { "_index" : "12_assets_directory_v1","_type" : "_doc" }}
{ "file_name": "","file_type": "table","database_name": "geespace_bd_platform_dev","table_name": "103_addserialnumber_2","include_fields": "","source_business": 1,"store_type": "mysql","whether_online": 0,"foreign_id": 11,"update_time": 1618560193030}

注意:每个json串不能换行,只能放到一行
详情查看->https://blog.csdn.net/chen18677338530/article/details/93067493

本人先关其他文章链接

1.ElasticSearch7.6.x 模板及滚动索引创建及注意事项
https://blog.csdn.net/a924382407/article/details/115082265

2.ElasticSearch的IK分词器
https://blog.csdn.net/a924382407/article/details/117255506

3.ElasticSearch核心概念:倒排索引
https://blog.csdn.net/a924382407/article/details/117255449

4.springboot集成ElasticSearch使用completion实现补全功能
https://blog.csdn.net/a924382407/article/details/115868167

5.ES Restful API讲解使用
https://blog.csdn.net/a924382407/article/details/115085022

6.ES API,使用Kibana的开发工具用例说明
https://blog.csdn.net/a924382407/article/details/115084549

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/106301.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!