Skip to content

Instantly share code, notes, and snippets.

@SeRGei93
Created February 11, 2024 22:01
Show Gist options
  • Save SeRGei93/1fe6782388007b7d6de96c38c4694b63 to your computer and use it in GitHub Desktop.
Save SeRGei93/1fe6782388007b7d6de96c38c4694b63 to your computer and use it in GitHub Desktop.
query
{
"query": {
"bool": {
"must": [
{
"terms": {
"active": [
true
]
}
},
{
"terms": {
"canBuy": [
true
]
}
},
{
"terms": {
"sections": [
3233
]
}
}
]
}
},
"post_filter": {
"bool": {
"filter": [
{
"nested": {
"path": "textFacets",
"query": {
"bool": {
"filter": [
{
"term": {
"textFacets.id": {
"value": "obem-vstroennoy-pamyati"
}
}
},
{
"terms": {
"textFacets.value": [
"128-gb",
"256-gb"
]
}
}
]
}
}
}
},
{
"nested": {
"path": "textFacets",
"query": {
"bool": {
"filter": [
{
"term": {
"textFacets.id": {
"value": "brand"
}
}
},
{
"terms": {
"textFacets.value": [
"apple",
"samsung"
]
}
}
]
}
}
}
}
]
}
},
"aggs": {
"aggs_all_filters": {
"filter": {
"bool": {
"filter": [
{
"nested": {
"path": "textFacets",
"query": {
"bool": {
"filter": [
{
"term": {
"textFacets.id": "brand"
}
},
{
"terms": {
"textFacets.value": [
"apple",
"samsung"
]
}
}
]
}
}
}
},
{
"nested": {
"path": "textFacets",
"query": {
"bool": {
"filter": [
{
"term": {
"textFacets.id": "obem-vstroennoy-pamyati"
}
},
{
"terms": {
"textFacets.value": [
"128-gb",
"256-gb"
]
}
}
]
}
}
}
}
]
}
},
"aggs": {
"facets": {
"nested": {
"path": "textFacets"
},
"aggs": {
"names": {
"terms": {
"field": "textFacets.id"
},
"aggs": {
"values": {
"terms": {
"field": "textFacets.value"
}
}
}
}
}
}
}
},
"aggs_brand": {
"filter": {
"bool": {
"filter": [
{
"nested": {
"path": "textFacets",
"query": {
"bool": {
"filter": [
{
"term": {
"textFacets.id": "obem-vstroennoy-pamyati"
}
},
{
"terms": {
"textFacets.value": [
"128-gb",
"256-gb"
]
}
}
]
}
}
}
}
]
}
},
"aggs": {
"facets": {
"nested": {
"path": "textFacets"
},
"aggs": {
"aggs_special": {
"filter": {
"match": {
"textFacets.id": "brand"
}
},
"aggs": {
"names": {
"terms": {
"field": "textFacets.id"
},
"aggs": {
"values": {
"terms": {
"field": "textFacets.value"
}
}
}
}
}
}
}
}
}
}
},
"size": 0
}
Result
{
"took": 23,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 154,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"aggs_brand": {
"doc_count": 495,
"facets": {
"doc_count": 8961,
"aggs_special": {
"doc_count": 494,
"names": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "brand",
"doc_count": 494,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 8,
"buckets": [
{
"key": "xiaomi",
"doc_count": 140
},
{
"key": "samsung",
"doc_count": 81
},
{
"key": "apple",
"doc_count": 73
},
{
"key": "huawei",
"doc_count": 38
},
{
"key": "honor",
"doc_count": 34
},
{
"key": "infinix",
"doc_count": 34
},
{
"key": "realme",
"doc_count": 29
},
{
"key": "tecno",
"doc_count": 25
},
{
"key": "vivo",
"doc_count": 20
},
{
"key": "tcl",
"doc_count": 12
}
]
}
}
]
}
}
}
},
"aggs_all_filters": {
"doc_count": 154,
"facets": {
"doc_count": 2789,
"names": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 1249,
"buckets": [
{
"key": "audiovyhod",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "lightning",
"doc_count": 73
},
{
"key": "usb-type-c",
"doc_count": 63
},
{
"key": "jack-3-5-mm",
"doc_count": 18
}
]
}
},
{
"key": "bluetooth",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "5-3",
"doc_count": 67
},
{
"key": "5-0",
"doc_count": 60
},
{
"key": "5-1",
"doc_count": 15
},
{
"key": "5-2",
"doc_count": 12
}
]
}
},
{
"key": "brand",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "samsung",
"doc_count": 81
},
{
"key": "apple",
"doc_count": 73
}
]
}
},
{
"key": "cvet-korpusa",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 25,
"buckets": [
{
"key": "chernyy",
"doc_count": 44
},
{
"key": "belyy",
"doc_count": 22
},
{
"key": "fioletovyy",
"doc_count": 15
},
{
"key": "siniy",
"doc_count": 13
},
{
"key": "zelenyy",
"doc_count": 9
},
{
"key": "zolotistyy",
"doc_count": 7
},
{
"key": "seryy",
"doc_count": 6
},
{
"key": "serebristyy",
"doc_count": 5
},
{
"key": "bezhevyy",
"doc_count": 4
},
{
"key": "lavandovyy",
"doc_count": 4
}
]
}
},
{
"key": "format-fizicheskoy-sim-karty",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "nano",
"doc_count": 118
},
{
"key": "nano--plus-esim",
"doc_count": 30
},
{
"key": "nano--plus-nano-esim",
"doc_count": 6
}
]
}
},
{
"key": "kolichestvo-yader-processora",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "8",
"doc_count": 81
},
{
"key": "6",
"doc_count": 73
}
]
}
},
{
"key": "material-korpusa",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "steklo",
"doc_count": 80
},
{
"key": "plastik",
"doc_count": 59
},
{
"key": "metall",
"doc_count": 57
},
{
"key": "alyuminiy",
"doc_count": 41
},
{
"key": "nerzhaveyuschaya-stal",
"doc_count": 3
}
]
}
},
{
"key": "obem-operativnoy-pamyati",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "6-gb",
"doc_count": 62
},
{
"key": "4-gb",
"doc_count": 43
},
{
"key": "8-gb",
"doc_count": 34
},
{
"key": "3-gb",
"doc_count": 10
},
{
"key": "12-gb",
"doc_count": 5
}
]
}
},
{
"key": "obem-vstroennoy-pamyati",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "128-gb",
"doc_count": 113
},
{
"key": "256-gb",
"doc_count": 41
}
]
}
},
{
"key": "podderzhka-standartov-svyazi",
"doc_count": 154,
"values": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 97,
"buckets": [
{
"key": "lte-4g",
"doc_count": 154
},
{
"key": "hspa-plus-3-75g",
"doc_count": 127
},
{
"key": "gsm-2g",
"doc_count": 125
},
{
"key": "umts-3g",
"doc_count": 119
},
{
"key": "edge-2-9g",
"doc_count": 115
},
{
"key": "5g",
"doc_count": 103
},
{
"key": "hspa-3-5g",
"doc_count": 83
},
{
"key": "gprs-2-5g",
"doc_count": 52
},
{
"key": "wcdma-3g",
"doc_count": 34
},
{
"key": "gprs-2g",
"doc_count": 21
}
]
}
}
]
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment