提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
- Kibana查数
- 1.查询所有记录
- 2.匹配id字段
- match
- term
- 3.bool[复合查询]
- 4.业务查询
Kibana查数
在ElasticSearch中支持两种检索方式
- 通过使用REST request URL 发送检索参数(uri+检索参数)
- 通过使用 REST request body 来发送检索参数 (uri+请求体)
1.查询所有记录
- 查询 audience_index:客户档案索引下所有文档数
GET audience_index/_search
{
"query":{
"match_all" : {}
}
}
2.匹配id字段
查询客户id “audid”: 299433415672006
match
GET audience_index/_search
{
"query":{
"match" : {
"audid": 299433415672006
}
}
}
term
GET audience_index/_search
{
"query": {
"term": {
"audid": {
"value": "299433415672006"
}
}
}
}
GET audience_index/_search
{
"query": {
"bool": {
"filter": {
"terms": {
"audid": ["299433415672006"]
}
}
}
}
}
3.bool[复合查询]
- must
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"audid": "299433415671936"
}},
{
"match": {
"base.deleted": "0"
}}
]
}
}
}
- term
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"audid": "299433415671936"
}},
{
"term": {
"base.deleted": "0"
}}
]
}
}
}
- must +filter
GET audience_index/_search
{
"query": {
"bool": {
"must": [ {
"term": {
"audid": 299433415671936
}
}] ,
"filter": {
"term": {
"base.deleted": "0"
}
}
}
}
}
4.业务查询
一、客户列表-通过客户自选标签筛选客户(ES)
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"appTag": "10"
}
},
{
"term": {
"base.status": 1
}
}
]
}
},
"size": 100
}
二、客户列表-通过公众号关注日期筛选客户
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"base.custom.subscribeTime": {
"gte": "2023-06-12 00:00:00",
"lte": "2023-06-12 23:59:59"
}
}
},
{
"term": {
"base.status": 1
}
}
]
}
},
"size": 200
}
三、客户列表-通过客户创建时间筛选客户
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"createTime": {
"gte": 1682870400000,
"lte": 1686499199000
}
}
},
{
"term": {
"base.status": 1
}
}
]
}
},
"size": 200
四、通过客户分组查看分组内的客户
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"group": {
"value": "1447-4"
}
}
},
{
"term": {
"base.status": 1
}
}
]
}
},
"size": 200
}
五、通过APP客户自选标签查看满足条件的客户
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"appTag": "21"
}
},
{
"term": {
"base.status": 1
}
},
{
"term": {
"uid.source": {
"value": "phone"
}
}
}
]
}
},
"size": 200
}
六、通过APP客户自选标签,筛选满足发送条件的客户(内容推送和客户投放)
GET audience_index/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"appTag": "21"
}
},
{
"term": {
"base.status": 1
}
},
{
"term": {
"uid.source": {
"value": "weiyinhang"
}
}
}
]
}
},
"size": 200
}