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"
		}
	}]
}
相关推荐
G31135422732 分钟前
如何用 QClaw 龙虾做一个规律作息健康助理 Agent
大数据·人工智能·ai·云计算
幂律智能3 分钟前
零售行业合同管理数智化转型解决方案
大数据·人工智能·零售
快乐非自愿10 分钟前
Redis--SDS字符串与集合的底层实现原理
数据库·redis·缓存
华万通信king12 分钟前
WorkBuddy知识库企业级搭建实战:从零到生产级别的完整路径
大数据·人工智能
智慧景区与市集主理人17 分钟前
五一市集分账混乱?巨有科技智慧市集小程序实现统一收款、自动分账
大数据·科技·小程序
这儿有一堆花25 分钟前
住宅代理(Residential Proxy)技术指南
开发语言·数据库·php
互联网志32 分钟前
政策赋能校产融合 推动高校科技成果落地生根
大数据·人工智能·物联网
茉莉玫瑰花茶1 小时前
LangChain 核心组件 [ 2 ]
java·数据库·langchain
GIS数据转换器1 小时前
“一张图”背景下的地质灾害监测预警与防治能力建设
大数据·人工智能·数据分析·无人机·智慧城市
Elastic 中国社区官方博客1 小时前
在 Elastic 中使用 MCP 自动化用户旅程以进行合成监控
大数据·运维·人工智能·elasticsearch·搜索引擎·自动化·可用性测试