ES API,使用Kibana的开发工具用例说明
【摘要】 ES API,使用Kibana的开发工具用例说明
@[TOC]
创建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
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)