elasticsearch搜索入门
- 查看index
- 查看node节点
- where treeCodes like '%xx%' order by createTime desc
- select count(*) from where treeCode like '%7330934%'
- select * from where treeCodes like '%xxx%';
- select enterpriseId,targetId where actionType = 1 order by enterpriseId desc
- where actionType = 1 order by enterpriseId desc
- where actionType = 1 limit 0 ,20
- where actionType = 1 group by enterpriseId
- where actionType = 1 group by accountId
- where accountId = ? and actionType in()
- group by accountId
- where accountId = ? and actionType in() group by accountId
查看index
GET /_cat/indices?v
查看node节点
GET /_cat/nodes?v
where treeCodes like ‘%xx%’ order by createTime desc
GET env_account_change_2022_03_10/_search
{
“query”: {“match_phrase”: {
“treeCodes”: “729587218411520”
}},“sort”: [
{
“createTime”: {
“order”: “desc”
}
}
]
}
select count(*) from where treeCode like ‘%7330934%’
GET account_change_2022_03_09/_count
{
“query”: {“match_phrase”: {
“treeCodes”: 733093426640896
}
}
}
select * from where treeCodes like ‘%xxx%’;
GET account_change_2022_03_09/_search
{
“query”: {“match_phrase”: {
“treeCodes”: 733093426640896
}
}
}
select enterpriseId,targetId where actionType = 1 order by enterpriseId desc
GET account_change_2022_03_09/_search
{
“query”: {“match”: {
“actionType”: 1
}
},"_source": [“enterpriseId”,“targetId”]
}
where actionType = 1 order by enterpriseId desc
GET account_change_2022_03_09/_search
{
“query”: {“match”: {
“actionType”: 1
}
},“sort”: [
{
“enterpriseId”: {
“order”: “desc”
}
}
]
}
where actionType = 1 limit 0 ,20
GET account_change_2022_03_09/_search
{
“query”: {“match”: {
“actionType”: 1
}
},“size”: 20,“from”:0
}
where actionType = 1 group by enterpriseId
GET account_change_2022_03_09/_search
{
“query”: {“match”: {
“actionType”: 1
}
},“size”: 0,
“aggs”: {
“group_by_sector”: {
“terms”: {
“field”: “enterpriseId”,
“size”: 10
}
}
}
}
where actionType = 1 group by accountId
GET dev104_account_action_event_2022_03_09/_search
{
“size”: 0,
“query”: {
“match”: {
“actionType”: 1
}
},
“aggs”: {
“group_by_state”: {
“terms”: {
“field”: “accountId”
}
}
}
}
where accountId = ? and actionType in()
GET dev104_account_action_event_2022_03_09/_search
{
“query”: {
“bool”: {
“must”: [
{“match”: {
“accountId”: “730856098557952”
}}
],
“should”: [
{“match”: {
“actionType”: 1
}},
{
“match”: {
“actionType”: 2
}
}
]
}
}
}
group by accountId
GET dev104_account_action_event_2022_03_09/_search
{
“size”: 0,
“aggs”: {
“group_by_state”: {
“terms”: {
“field”: “accountId”
}
}
}
}
where accountId = ? and actionType in() group by accountId
GET dev104_account_action_event_2022_03_09/_search
{
“size”: 0,
“query”: {
“bool”: {
“must”: [
{“match”: {
“accountId”: “730856098557952”
}}
],
“should”: [
{“match”: {
“actionType”: 1
}},
{
“match”: {
“actionType”: 2
}
}
]
}
},
“aggs”: {
“group_by_state”: {
“terms”: {
“field”: “accountId”
}
}
}
}
参考: https://mp.weixin.qq.com/s?__biz=MzU1Nzg4NjgyMw%3D%3D&idx=1&mid=2247484699&scene=21&sn=5367206c3c3da2278821dd9fad648850#wechat_redirect