es常用命令
where(and in) (and not in)select * from order-202001 where contract_type = 1 and order_type in (0,1,2,3,4,5,8,9,10) and platform_shopid not in (72,166)GET order-202101/_search{"query": {"bool": {"must
借助kibana
每次请求kibana请求都可以看到请求中的query参数看到QSL
where
(and in) (and not in)
select * from order-202001 where contract_type = 1 and order_type in (0,1,2,3,4,5,8,9,10) and platform_shopid not in (72,166)
GET order-202101/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"contract_type": {
"value": 1
}
}
},
{
"terms": {
"order_type": [
0,1,2,3,4,5,8,9,10
]
}
}
],
"must_not": [
{
"terms": {
"platform_shopid": [
72,166
]
}
}
]
}
}
}
or
GET dispatch_tracer_filter-2021.01.31.09/_search
{
"query": {
"bool": {
"should": [
{
"prefix": {
"filterRiderList.name": {
"value": "顺路度"
}
}
},
{
"term": {
"cityId": {
"value": "45"
}
}
}
],
"minimum_should_match": 1
}
}
}
group by
(between and)
select rider_id,count(id) from order-202011 where rider_id in (…) and platform_shopid=161 and finish_tm between date1 and date2 group by rider_id
GET /order-202011/_search
{
"size": 10,
"query": {
"bool" : {
"filter": {
"terms": {
"rider_id": [
5593548,319701,5599521,5596906,5589792,5574022,5570959,5568386,5434909,5230436,5222181,5154695,3375081,3323860,2708667,2652136,365288,5602218
]
}
},
"must": [
{
"term": {
"platform_shopid": {
"value": "161"
}
}
}
],
"should": [
{
"range": {
"finish_tm": {
"gte": "2020-11-11 00:00:00",
"lt": "2020-11-12 00:00:00"
}
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"aggs": {
"rider": {
"terms": {
"field": "rider_id",
"size": 2000
},
"aggs": {
"count": {
"cardinality": {
"field": "id"
}
}
}
}
}
}
like
like ‘%key%’
select * from system-dispatch-2018.08.07 where content like ‘%过滤器%’ and content not like ‘%*:[]’ and (timestamp>=date1 or order_id between 1 and 2)
前提是content字段类型设置为keyword
GET system-dispatch-2018.08.07/_search
{
"size": 200,
"query": {
"bool": {
"must": [
{
"match_phrase": {
"content": {
"query": "过滤器"
}
}
}
],
"must_not": [
{
"wildcard": {
"content.keyword": "*:[]"
}
}
],
"should": [
{
"range": {
"@timestamp": {
"gte": "2018-08-07T15:00:00.000Z"
}
}
},
{
"range": {
"orderId": {
"gte": 332605574338378240,
"lte": 332605574338378240
}
}
}
],
"minimum_should_match": 1
}
}
}
not like ‘key%’
GET dispatch_tracer_filter-2021.01.31.09/_search
{
"query": {
"bool": {
"must_not": [
{
"prefix": {
"filterRiderList.name": {
"value": "顺路度"
}
}
}
]
}
}
}
kibana查看es版本
GET /
// 响应结果
{
"name": "node3",
"cluster_name": "test",
"cluster_uuid": "haha",
"version": {
"number": "5.3.0",
"build_hash": "111hash",
"build_date": "2017-03-23T03:31:50.652Z",
"build_snapshot": false,
"lucene_version": "6.4.1"
},
"tagline": "You Know, for Search"
}
monitor
查询所有索引状态
https://your-es-host/_cat/indices?v&pretty
输出结果:https://www.elastic.co/guide/en/elasticsearch/reference/8.6/cat-indices.html
Use the cat indices API to get the following information for each index in a cluster:
1. Shard count
2. Document count
3. Deleted document count
4. Primary store size
5. Total store size of all shards, including shard replicas
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open order_history_v1_202302 4r07ExpfQWOl7XcMJy6w5A 1 0 704865 0 330.4mb 330.4mb
green open transaction_v2 YIEpn8qaR2aU7bBeINr34A 1 1 0 0 416b 208b
green open asset_info dVRh5pg-Speo9HZv8CSVuQ 3 1 1 0 12.2kb 6.1kb
green open test-index g1hPk_eeRMKoAL9TKh5iCg 1 1 2 0 12.7kb 6.3kb
green open test_num EqvOYAQFSvCTH_In03RWOQ 1 0 4 0 12.5kb 12.5kb
green open index_admin_opt_log_2023_0 GS9sLPFvQs6uRInvySjkqA 5 1 1112 0 1.5mb 834.3kb
green open user_v2 cW72zE07RcmjcBBv3zfwrg 3 1 2 0 13.2kb 8.5kb
green open token_sale_v1 bQ8vaJpPS-SMomarekt00w 1 1 2 0 29.3kb 14.6kb
green open .kibana_1 WZSlFnbOTMq4V2gWh9Em1g 1 1 1 0 10.1kb 5kb
green open user qAkOZYd-RQ-Ez3x7h-qSjA 3 1 2 0 15.1kb 7.5kb
green open transaction yU9hzoi2QVmhGHiv0XkTRA 3 1 2 0 53.9kb 26.9kb
green open user_operation_log_v1_202212 uh1vH1C0QSKk6D-XN-rk9g 2 1 1 0 16.4kb 8.2kb
查询shard状态
curl --location 'https://your-es-host/order_history_v1_202302/_shard_stores?status=all' \
--data ''
查询mapping
curl --location 'https://your-es-host/order_history_v1_202302/_mapping' \
--data ''
查询索引状态
curl --location 'https://your-es-host/order_history_v1_202302/_stats' \
--data ''
查询索引配置
curl --location 'https://your-es-host/token_sale_v1' \
--data ''
批量删除
curl --location 'https://your-es-host/token_sale_v1/_delete_by_query?conflicts=proceed&scroll_size=10000&wait_for_completion=false' \
--header 'Content-Type: application/json' \
--data '{
"query": {
"bool": {
"must": [
{
"range": {
"id": {
"lte": 0
}
}
}
]
}
}
}'
分词器
查看某个字段的分词
curl --location --request GET 'https://my_es_host/MY_INDEX/_termvectors/MY_DOC_ID?fields=MY_FIELD_NAME'
查看某个分词器的分词结果
curl --location --request GET 'https://my_es_host/_analyze' \
--header 'Content-Type: application/json' \
--data '{
"analyzer": "standard",
"text": "Hello es !!! Jack-chen"
}'
分词器 | 功能 |
---|---|
Standard Analyzer | 默认分词器,按词切分,小写处理 |
Simple Analyzer | 按照非字母切分(符号被过滤), 小写处理 |
Stop Analyzer | 小写处理,停用词过滤(the,a,is) |
Whitespace Analyzer | 按照空格切分,不转小写 |
Keyword Analyzer | 不分词,直接将输入当作输出 |
Patter Analyzer | 正则表达式,默认\W+(非字符分割) |
Language | 提供了30多种常见语言的分词器 |
Customer Analyzer | 自定义分词器 |
查看配置
https://myhost/_cluster/settings?include_defaults&flat_settings
更多推荐
所有评论(0)