demo1
{
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"subscribe": 1
}
},
{
"bool": {
"should": [
{
"term": {
"mid": "55"
}
},
{
"term": {
"mid": "65"
}
},
{
"term": {
"mid": "70"
}
},
{
"term": {
"mid": "71"
}
},
{
"term": {
"mid": "86"
}
}
]
}
}
],
"must_not": {
"term": {
"unid": ""
}
}
}
},
"aggs": {
"group_by_unid": {
"terms": {
"field": "unid",
"size":0
}
}
}
}
demo2
sql:$sql = "SELECT count(*) as count,type FROM user_action_record
WHERE wid={$mid} AND type in('menu','custom_data_event','lbs','message') AND created_date>={$startintdate} AND created_date<={$endintdate} GROUP BY type";
{
"size": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"wid": 33
}
},
{
"range": {
"created_date": {
"gte": "20160701",
"lte": "20160731"
}
}
},
{
"bool": {
"should": [
{
"term": {
"type": "menu"
}
},
{
"term": {
"type": "custom_data_event"
}
},
{
"term": {
"type": "lbs"
}
},
{
"term": {
"type": "message"
}
}
]
}
}
]
}
}
}
},
"aggs": {
"group_by_type": {
"terms": {
"field": "type"
}
}
}
}
demo3
sql:"SELECT wid as mid,openid,type,create_time FROM user_action_record
WHERE wid={$mid} AND openid ='{$order['openid']}' AND create_time>='{$beforeday}' AND create_time<='{$order['create_time']}' AND type not in ($filter_str) ORDER BY create_time DESC LIMIT 1;
{
"size": 1,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"terms": {
"wid": 33,
}
},
{
"term": {
"openid": "oOuXGtyW8yZM7EZ_IfLsKgTJr6hM"
}
},
{
"range": {
"create_time": {
"gte": "0000000000",
"lte": "1472659200"
}
}
},
{
"bool": {
"must_not": [
{
"term": {
"type": "subscribe"
}
},
{
"term": {
"type": "unsubscribe"
}
},
{
"term": {
"type": "scratch"
}
},
{
"term": {
"type": "wheel_of_fortune"
}
}
]
}
}
]
}
}
}
},
"sort": {
"create_time": {
"order": "desc"
}
}
}
demo4
sql: SELECT count(DISTINCT(openid)) AS taged FROM wechat_customer_tag
WHERE mid = 71 AND STATUS = 1 AND create_time < '2016-09-19 23:59:59';
{
"aggs": {
"followers_counts": {
"value_count": {
"field": "id"
}
}
},
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"mid": 33
}
},
{
"has_child": {
"type": "wechat_customer_tag",
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"mid": "33"
}
},
{
"term": {
"status": 1
}
},
{
"range": {
"create_time": {
"lte": "1474300799"
}
}
}
]
}
}
}
}
}
}
]
}
}
}
}
}
demo5
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"mid": "35"
}
},
{
"has_child": {
"type": "user_action_record",
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"wid": "35"
}
},
{
"terms": {
"type": [
"read",
"readmore",
"shares_reads",
"share_post"
]
}
},
{
"wildcard": {
"keyword": "*42@0*"
}
},
{
"range": {
"create_time": {
"from": 1471708800,
"to": 1474387199
}
}
}
]
}
}
}
}
}
}
]
}
}
}
},
"aggregations": {
"group_by_sex": {
"terms": {
"field": "sex"
}
}
}
}
demo6
{
"query": {
"bool": {
"must": {
"term": {
"mid": 33
}
}
}
},
"size": 0,
"aggs": {
"group_by_tag": {
"terms": {
"field": "tag_id_integer",
"order": {
"tagcount": "desc"
},
"size": 0
},
"aggs": {
"tagcount": {
"sum": {
"field": "count"
}
}
}
}
}
}
demo7
SELECT count(*) as click FROM user_action_record
WHERE wid={$mid} AND type='menu' AND created_date>={$startdate} AND created_date<={$enddate}";
{
"aggs": {
"followers_counts": {
"value_count": {
"field": "id"
}
}
},
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"wid": 71
}
},
{
"term": {
"type": "menu"
}
},
{
"range": {
"created_date": {
"gte": "20160901",
"lte": "20160930"
}
}
}
]
}
}
}
}
}