Skip to content

Instantly share code, notes, and snippets.

@guerbai
Last active February 3, 2020 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guerbai/2642b46aa2a4c3bb2bace031475687de to your computer and use it in GitHub Desktop.
Save guerbai/2642b46aa2a4c3bb2bace031475687de to your computer and use it in GitHub Desktop.
es查询收集 #ElasticSearch
{
"size": 0,
"aggs": {
"path": {
"filter": {
"bool": {
"filter": [
{"term": {"file_type": 150}}
]
}
},
"aggs": {
"cnt": {
"cardinality": {"field": "file_id"}
}
}
}
}
}
{
"size": 0,
"aggs": {
"object_id_info": {
"filter": {
"bool": {
"filter": [
{"term": {"object_type": 51}},
{"match_phrase": {"name": "savage"}}
]
}
},
"aggs": {
"group_by_object_id": {
"terms": {
"field": "object_id",
"size": 500
},
"aggs": {
"review_ids": {
"scripted_metric": {
"init_script": "state.transactions = []",
"map_script": "state.transactions.add(doc['id'].value)",
"combine_script": "state.transactions",
"reduce_script": "List ids = new ArrayList(); for (i in states) {ids.addAll(i)} return ids"
}
}
}
}
}
}
}
}
{
"size": 0,
"aggs": {
"path": {
"filter": {
"bool": {
"filter": []
}
},
"aggs": {
"group_by_privince" : {
"terms": {
"field": privince,
"size": 100
},
"aggs": {
"final_price_total": {
"sum": {
"field": "final_price"
}
},
"initial_price_total": {
"sum": {
"field": "initial_price"
}
}
}
}
}
}
}
}
{
"size": 0,
"aggs": {
"path": {
"filter": {
"bool": {
"filter": []
}
},
"aggs": {
"group_by_time": {
"range": {
"field": "end_time",
"ranges": []
}
}
}
}
}
}
{
"query": {
"bool": {
"must": [
{
"bool": {
"minimum_should_match": "1",
"should": [
{
"constant_score": {
"boost": 200,
"filter": {
"match_phrase": {
"display_album": {
"query": "album1"
}
}
}
}
},
{
"constant_score": {
"boost": 10000,
"filter": {
"term": {
"display_album.keyword": "album1"
}
}
}
}
]
}
},
{
"terms": {
"company": [
1124
]
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment