Aggregations query not returning response on Elasticsearch 7.5

Hi, I am trying to run an ES query based on aggregations. It runs and returns a response in ES 2.4 but when I try to run the query in ES 7.5, it returns a response with empty buckets. Below is my query:

Elasticsearch 7.5 query

GET index_name/_search
{
     "aggs": {
            "category": {
                "nested": {
                    "path": "model.model_info"
                },
                "aggs": {
                    "tags": {
                        "terms": {
                            "field": "model.model_info.tags.raw",
                            "size": 1000
                        }
                    },
                    "sort_price_type": {
                        "terms": {
                            "field": "model.model_info.price_type",
                            "size": 100
                      }
                    }
                }
            }
     }
}

Response in Elasticsearch 7.5

{
   "took": 14,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "skipped": 0,
      "failed": 0
   },
   "hits": {
      "total": {
         "value": 0,
         "relation": "eq"
      },
      "max_score": null,
      "hits": []
   },
   "aggregations": {
      "category_data": {
         "doc_count": 0,
         "tags": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
         },
         "price_type": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
         }
      }
   }
}

For Elasticsearch 2.4 query works very well and looks is like this:

GET index_name/doc_type/_search
{
     "aggs": {
            "category": {
                "nested": {
                    "path": "model.model_info"
                },
                "aggs": {
                    "tags": {
                        "terms": {
                            "field": "model.model_info.tags.raw",
                            "size": 1000
                        }
                    },
                    "sort_price_type": {
                        "terms": {
                            "field": "model.model_info.price_type",
                            "size": 100
                      }
                    }
                }
            }
     }
}

I'm using the same mappings for both the queries:

"tags": map[string]interface{}{
    "type": "text",
    "fields": map[string]interface{}{
        "raw": map[string]interface{}{
	         "type":  "keyword",
	         "index": true,
         },
     },
},
"price_type": map[string]interface{}{
		"type":      "text",
		"fielddata": true,
},

Both price_type and tags are nested inside model.model_info fields.

It would be great if anyone can help me with this issue and make the queries run on both ES 2.4 and ES 7.5. I tried a lot to debug and make it work but still I'm not able to figure out my mistake. Thanks in advance :slight_smile:

It would be great if anyone can help me with issue, I'm still not able to fix it.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.