Skip to content

Instantly share code, notes, and snippets.

@FrankHassanabad
Last active July 8, 2021 00:14
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 FrankHassanabad/5290eaf253ca6348937ff06617f2899c to your computer and use it in GitHub Desktop.
Save FrankHassanabad/5290eaf253ca6348937ff06617f2899c to your computer and use it in GitHub Desktop.
Behavioral bug between the terms_enum and terms_agg for the KQL bar.
# New behavior which does NOT allow us to use "-*elastic-cloud-logs-*" if it does not exist
# to subtract. Instead this blows up with a 404 error which causes a cascading 500 internal server error
POST /auditbeat-*,filebeat-*,logs-*,winlogbeat-*,-*elastic-cloud-logs-*/_terms_enum
{
"field": "host.name",
"string": "",
"index_filter": {
"bool": {
"must": [
{
"terms": {
"_tier": [
"data_hot",
"data_warm",
"data_content",
"data_cold"
]
}
}
]
}
}
}
# error returned is:
{
"error" : {
"root_cause" : [
{
"type" : "index_not_found_exception",
"reason" : "no such index [*elastic-cloud-logs-*]",
"index_uuid" : "_na_",
"index" : "*elastic-cloud-logs-*"
}
],
"type" : "index_not_found_exception",
"reason" : "no such index [*elastic-cloud-logs-*]",
"index_uuid" : "_na_",
"index" : "*elastic-cloud-logs-*"
},
"status" : 404
}
# Older terms_aggs behavior which allows us to use "-*elastic-cloud-logs-*" if it does not exist to subtract.
# However it will not allow non-existent indexes if they are not prefixed with a dash
GET /auditbeat-*,filebeat-*,logs-*,winlogbeat-*,-*elastic-cloud-logs-*/_search
{
"size": 0,
"timeout": "1000ms",
"terminate_after": 100000,
"query": {
"bool": {
"filter": []
}
},
"aggs": {
"suggestions": {
"terms": {
"field": "host.name",
"include": ".*",
"execution_hint": "map",
"shard_size": 10
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment