Below is my request . In was getting aggregation for all except attributes i dont know where it was going wrong. Could you help me?
{
"min_score": 0.5,
"size": 500,
"_source": true,
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "Nivi",
"type": "best_fields",
"tie_breaker": 0.3,
"minimum_should_match": "100%",
"fields": [
"_doc_id^2",
"_doc_name",
"autocomplete_all",
"descrip1",
"descrip2",
"descrip3",
"lookup_all",
"token_all"
]
}
}
],
"filter": [
{
"bool": {
"must": [
{
"match": {
"tenant_id": "DEFAULT"
}
},
{
"terms": {
"cono": [
5000,
0
]
}
},
{
"terms": {
"record_type": [
"icsp"
]
}
}
]
}
}
],
"must_not": [
{
"nested": {
"path": "filters",
"query": {
"bool": {
"should": [
{
"match": {
"filters.activefl": false
}
}
]
}
}
}
},
{
"nested": {
"path": "filters",
"query": {
"bool": {
"should": [
{
"match": {
"filters.statustype": "i"
}
}
]
}
}
}
}
]
}
},
"aggs": {
"filters": {
"nested": {
"path": "filters"
},
"aggs": {
"activefl": {
"terms": {
"field": "filters.activefl",
"size": 200
}
},
"apsvRowpointer": {
"terms": {
"field": "filters.apsvRowpointer",
"size": 200
}
},
"arscRowpointer": {
"terms": {
"field": "filters.arscRowpointer",
"size": 200
}
},
"arssRowpointer": {
"terms": {
"field": "filters.arssRowpointer",
"size": 200
}
},
"brandcode": {
"terms": {
"field": "filters.brandcode",
"size": 200
}
},
"countryoforigin": {
"terms": {
"field": "filters.countryoforigin",
"size": 200
}
},
"attributeGroup": {
"terms": {
"field": "filters.attributeGroup",
"size": 200
}
},
"icsdRowpointer": {
"terms": {
"field": "filters.icsdRowpointer",
"size": 200
}
},
"keyno": {
"terms": {
"field": "filters.keyno",
"size": 200
}
},
"kittype": {
"terms": {
"field": "filters.kittype",
"size": 200
}
},
"msdsfl": {
"terms": {
"field": "filters.msdsfl",
"size": 200
}
},
"nonstockty": {
"terms": {
"field": "filters.nonstockty",
"size": 200
}
},
"pricetype": {
"terms": {
"field": "filters.pricetype",
"size": 200
}
},
"prodcat": {
"terms": {
"field": "filters.prodcat",
"size": 200
}
},
"prodline": {
"terms": {
"field": "filters.prodline",
"size": 200
}
},
"prodtiergrp": {
"terms": {
"field": "filters.prodtiergrp",
"size": 200
}
},
"qtyavailAgg": {
"terms": {
"field": "filters.qtyavailAgg",
"size": 200
}
},
"rectype": {
"terms": {
"field": "filters.rectype",
"size": 200
}
},
"statustype": {
"terms": {
"field": "filters.statustype",
"size": 200
}
},
"unitbuy": {
"terms": {
"field": "filters.unitbuy",
"size": 200
}
},
"unitstock": {
"terms": {
"field": "filters.unitstock",
"size": 200
}
},
"attributes": {
"nested": {
"path": "filters.attributes"
},
"aggs": {
"attribute_value": {
"terms": {
"field": "filters.attributes.attribute_value",
"size": 200
}
}
}
}
}
}
}
}
Response to the above search
{
"took": 10083,
"hits": {
"hits": [
{
"_id": "c21055fa-291e-9e98-e613-96bf80093a0b",
"_source": {
"tenant_id": "DEFAULT",
"cono": 5000,
"token_all_es": "33-18",
"token_all_fr": "33-18",
"attributeGroup": "Krishna Kondapalli",
"token_all": "33-18 red heeler",
"filters": {
"unitstock": "Each",
"custno": 0,
"prodcat": "90",
"keyno": 0,
"rectype": "icsp",
"whse": "sx_empty",
"attributeGroup": "Krishna Kondapalli",
"msdsfl": false,
"attributes": [
{
"attribute_name": "Color",
"attribute_value": "Red"
},
{
"attribute_name": "Size",
"attribute_value": "Large"
},
{
"attribute_name": "Color",
"attribute_value": "Red"
},
{
"attribute_name": "Size",
"attribute_value": "Large"
},
{
"attribute_name": "Kittu",
"attribute_value": "Nivika"
}
],
"statustype": "A",
"shipto": "sx_empty"
},
"record_type": "icsp",
"lookupnm": "33-18",
"product_id": "33-18",
"descrip1": "red heeler",
"attributes": [
{
"attribute_name": "Color",
"attribute_value": "Red"
},
{
"attribute_name": "Size",
"attribute_value": "Large"
},
{
"attribute_name": "Color",
"attribute_value": "Red"
},
{
"attribute_name": "Size",
"attribute_value": "Large"
},
{
"attribute_name": "Kittu",
"attribute_value": "Nivika"
}
],
"token_all_en": "33-18",
"transdttmz": 1703264085602,
"lookup_all": "90 Each"
}
}
]
},
"aggregations": {
"filters": {
"unitstock": {
"buckets": [
{
"key": "EACH",
"doc_count": 1
}
]
},
"rectype": {
"buckets": [
{
"key": "ICSP",
"doc_count": 1
}
]
},
"attributeGroup": {
"buckets": [
{
"key": "Krishna Kondapalli",
"doc_count": 1
}
]
},
"prodcat": {
"buckets": [
{
"key": "90",
"doc_count": 1
}
]
},
"keyno": {
"buckets": [
{
"key": 0,
"doc_count": 1
}
]
},
"msdsfl": {
"buckets": [
{
"key": 0,
"key_as_string": "false",
"doc_count": 1
}
]
},
"statustype": {
"buckets": [
{
"key": "A",
"doc_count": 1
}
]
}
}
}
}
Below is mappings
{
"products_test_v2": {
"mappings": {
"dynamic": "false",
"properties": {
"altlookupnm": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"altprod": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"attributeGroup": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"attributes": {
"type": "nested",
"properties": {
"attribute_name": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"attribute_value": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
}
}
},
"autocomplete_all": {
"type": "text",
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
},
"cono": {
"type": "integer"
},
"descrip1": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip1_en": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip1_es": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip1_fr": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip2": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip2_en": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip2_es": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip2_fr": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip3": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip3_en": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip3_es": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"descrip3_fr": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"filters": {
"type": "nested",
"properties": {
"activefl": {
"type": "boolean"
},
"apssRowpointer": {
"type": "keyword"
},
"apsvRowpointer": {
"type": "keyword"
},
"arpvendno": {
"type": "long"
},
"arscRowpointer": {
"type": "keyword"
},
"arssRowpointer": {
"type": "keyword"
},
"attributeGroup": {
"type": "keyword"
},
"attributes": {
"type": "nested",
"properties": {
"attribute_name": {
"type": "keyword"
},
"attribute_value": {
"type": "keyword"
}
}
},
"brandcode": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"countryoforigin": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"custno": {
"type": "long"
},
"divno": {
"type": "integer"
},
"icsdRowpointer": {
"type": "keyword"
},
"keyno": {
"type": "long"
},
"kittype": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"msdsfl": {
"type": "boolean"
},
"nonstockty": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"pricetype": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"prodcat": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"prodline": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"prodtiergrp": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"qtyavailAgg": {
"type": "boolean"
},
"rectype": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"shipto": {
"type": "keyword"
},
"statustype": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"unitbuy": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"unitstock": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
},
"whmstRowpointer": {
"type": "keyword"
},
"whse": {
"type": "keyword",
"normalizer": "uppercase_normalizer"
}
}
},
"lookup_all": {
"type": "text",
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
},
"lookupnm": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"mfgprod": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"product_id": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
},
"record_type": {
"type": "keyword"
},
"tenant_id": {
"type": "keyword"
},
"token_all": {
"type": "text",
"analyzer": "whitespace_analyzer"
},
"token_all_en": {
"type": "text",
"analyzer": "whitespace_analyzer"
},
"token_all_es": {
"type": "text",
"analyzer": "whitespace_analyzer"
},
"token_all_fr": {
"type": "text",
"analyzer": "whitespace_analyzer"
},
"transdttmz": {
"type": "date",
"format": "epoch_millis"
},
"vendprod": {
"type": "keyword",
"copy_to": [
"autocomplete_all"
]
}
}
}
}
}
````Preformatted text``Preformatted text`