Elasticsearch-kibana索引操作

1索引模版

添加索引

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
				}

			}
		}
	}
}

操作结果

查看索引

GET /_index_template/account_transaction

查看所有索引

GET /_cat/indices?v

2索引

创建索引

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

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

添加索引数据

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
        }

查询索引数据

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"
		}
	}]
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值