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"
		}
	}]
}
相关推荐
Python智慧行囊9 分钟前
Python Django 的 ORM 编程思想及使用步骤
数据库·python·django·orm
南方以南_38 分钟前
【云实验】Excel文件转存到RDS数据库
数据库·excel
万山y2 小时前
es快速上手(从MySQL角度)
mysql·elasticsearch·jenkins
Listennnn2 小时前
Neo4j数据库
数据库·人工智能·neo4j
小飞敲代码2 小时前
【Hadoop 实战】Yarn 模式上传 HDFS 卡顿时 “No Route to Host“ 错误深度解析与解决方案
大数据·linux·运维·服务器·hadoop·分布式·hdfs
Liu1bo2 小时前
【MySQL】库与表的操作
数据库·mysql·oracle
冬瓜的编程笔记3 小时前
【MySQL成神之路】MySQL常用语法总结
数据库·mysql
YJQ99673 小时前
Redis配置与优化:提升NoSQL数据库性能的关键策略
数据库·redis·nosql
@Turbo@3 小时前
【QT】一个界面中嵌入其它界面(二)
开发语言·数据库·qt
你的坚持终将美好,4 小时前
谷歌es插件elasticsearch-head.crx
大数据·elasticsearch·搜索引擎