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

创建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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘大猫.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值