Skip to content

[BUG] StarTree Profiling GlobalOrdinalsStringTermsAggregator sub aggregation #19649

@ajleong623

Description

@ajleong623

Describe the bug

I received an error

{
  "_shards": {
        "total": 2,
        "successful": 1,
        "skipped": 0,
        "failed": 1,
        "failures": [
            {
                "shard": 0,
                "index": "logs",
                "node": "1XceQRUISbSPx-XuWifF3A",
                "reason": {
                    "type": "class_cast_exception",
                    "reason": "class org.opensearch.search.profile.aggregation.ProfilingAggregator cannot be cast to class org.opensearch.search.aggregations.StarTreePreComputeCollector (org.opensearch.search.profile.aggregation.ProfilingAggregator and org.opensearch.search.aggregations.StarTreePreComputeCollector are in unnamed module of loader 'app')"
                }
            }
        ]
    }
}

This is because in the GlobalOrdinalsStringTermsAggregator.java, we are not accounting for the case where the inner aggregator might be wrapped with a profiling aggregator.

Related component

Search:Aggregations

To Reproduce

First, we want to create the index

PUT http://localhost:9200/logs

{
   "settings": {
       "index.number_of_shards": 2,
       "index.number_of_replicas": 0,
       "index.requests.cache.enable": false,
       "index.composite_index": true,
       "index.append_only.enabled": true
   },
   "mappings": {
       "dynamic": "strict",
       "_source": {
           "enabled": true
       },
       "composite": {
           "startree1": {
               "type": "star_tree",
               "config": {
                   "max_leaf_docs": 1,
                   "ordered_dimensions": [
                       {
                           "name": "status"
                       },
                       {
                           "name": "size"
                       },
                       {
                           "name": "clientip"
                       },
                       {
                       "name": "@timestamp",
                       "calendar_intervals": [
                           "month",
                           "day"
                       ]
                   }
                   ],
                   "metrics": [
                       {
                           "name": "size",
                           "stats": [
                               "sum",
                               "value_count",
                               "min",
                               "max"
                           ]
                       },
                       {
                           "name": "status",
                           "stats": [
                               "sum",
                               "vaLue_count",
                               "min",
                               "max"
                           ]
                       }
                   ]
               }
           }
       },
       "properties": {
           "@timestamp": {
               "format": "strict_date_optional_time||epoch_second",
               "type": "date"
           },
           "message": {
               "type": "keyword",
               "index": false,
               "doc_values": false
           },
           "clientip": {
               "type": "ip"
           },
           "request": {
               "type": "text",
               "fields": {
                   "raw": {
                       "ignore_above": 256,
                       "type": "keyword"
                   }
               }
           },
           "status": {
               "type": "float"
           },
           "size": {
               "type": "integer"
           },
           "geoip": {
               "properties": {
                   "country_name": {
                       "type": "keyword"
                   },
                   "city_name": {
                       "type": "keyword"
                   },
                   "location": {
                       "type": "geo_point"
                   }
               }
           }
       }
   }
}

Then, we want to create a document.

POST http://localhost:9200/logs/_doc

{
    "@timestamp": 1706537359,
    "clientip": "32.126.80.202",
    "request": "GET /spanish/contact.html HTTP/1.0",
    "status": 209,
    "size": 875
}

Enable star tree search

{
    "acknowledged": true,
    "persistent": {},
    "transient": {
        "indices": {
            "composite_index": {
                "star_tree": {
                    "enabled": "true"
                }
            }
        }
    }
}

Finally, run the actual search.

POST http://localhost:9200/logs/_search

{
    "profile": true,
    "size": 0,
    "aggs": {
        "response_codes": {
            "terms": {
                "field": "clientip",
                "size": 100
            },
            "aggs": {
                "sum_status": {
                    "sum": {
                        "field": "status"
                    }
                }
            }
        }
    }
}

Expected behavior

There should not be an error, but instead, the aggregations should return properly.

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions