Elasticsearch-kibana索引操作

1索引模版

添加索引

XML 复制代码
PUT /_index_template/account_transaction
{
	"priority": 0,
	"index_patterns": ["account_transaction*"],
	"template": {
		"settings": {
			"index": {
				"number_of_shards": "50",
				"number_of_replicas": "2",
				"refresh_interval": "1s"
			}
		},
		"mappings": {
			"dynamic": false,
			"_routing": {
				"required": false
			},
			"properties": {
				"pid": {
					"type": "long",
					"doc_values": true
				},
				"userId": {
					"type": "long",
					"doc_values": true
				},
				"asset": {
					"type": "keyword"
				},
				"tag": {
					"type": "keyword"
				},
				"tradeType": {
					"type": "byte",
					"doc_values": true
				},
				"preBalance": {
					"type": "long",
					"doc_values": true
				},
				"balance": {
					"type": "long",
					"doc_values": true
				},
				"preLocked": {
					"type": "long",
					"doc_values": true
				},
				"locked": {
					"type": "long",
					"doc_values": true
				},
				"context": {
					"type": "keyword"
				},
				"ctime": {
					"type": "long",
					"doc_values": true
				},
				"mtime": {
					"type": "long",
					"index": false
				}

			}
		}
	}
}

操作结果

查看索引

XML 复制代码
GET /_index_template/account_transaction

查看所有索引

XML 复制代码
GET /_cat/indices?v

2索引

创建索引

在有索引模版的情况下可以不需要创建操作,索引数据新增时会匹配是否存在对应的索引模版,例如我创建索引数据到account_transaction_001,

索引模版中的 "index_patterns": ["account_transaction*"],会匹配上这个索引,索引会按索引模版进行创建,再把数据添加到新索引中

添加索引数据

XML 复制代码
POST /account_transaction/_doc?
{
          "pid" : 1,
          "symbol" : "ETH-USDT",
          "userId" : 12121,
          "asset" : "USDT",
          "type" : "tag",
          "updateType" : 1,
          "preBalance" : 1222,
          "balance" : 1222,
          "preLocked" : 1222,
          "locked" : 1222,
          "context" : "context",
          "ctime" : 17465447927399,
          "mtime" : 17465447927399
        }

查询索引数据

XML 复制代码
GET /account_transaction/_search?
{
 	"query": {
		"bool": {
			"must": [{
				"term": {
					"userId": {
						"value": "12121",
						"boost": 1.0
					}
				}
			}
			],
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	},
	"sort": [{
		"ctime": {
			"order": "desc"
		}
	}]
}
相关推荐
Boilermaker19923 分钟前
【Java EE】SpringIoC
前端·数据库·spring
霸王龙的小胳膊17 分钟前
泛微虚拟视图-数据虚拟化集成
数据库
电商数据girl19 分钟前
有哪些常用的自动化工具可以帮助处理电商API接口返回的异常数据?【知识分享】
大数据·分布式·爬虫·python·系统架构
灵犀学长38 分钟前
解锁Spring Boot多项目共享Redis:优雅Key命名结构指南
数据库·redis
轩情吖40 分钟前
Qt的信号与槽(二)
数据库·c++·qt·信号·connect·信号槽·
ZeroNews内网穿透1 小时前
服装零售企业跨区域运营难题破解方案
java·大数据·运维·服务器·数据库·tcp/ip·零售
百胜软件@百胜软件1 小时前
重庆兰瓶×百胜软件正式签约,全渠道中台赋能美业新零售
大数据·零售
江瀚视野1 小时前
美团即时零售日订单突破1.2亿,即时零售生态已成了?
大数据·人工智能·零售
可观测性用观测云1 小时前
达梦数据库监控观测最佳实践
数据库
时序数据说1 小时前
IoTDB:专为物联网场景设计的高性能时序数据库
大数据·数据库·物联网·开源·时序数据库·iotdb