Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable aggregatable for special fields in index pattern #3284

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions libbeat/scripts/generate_index_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def fields_to_json(section, path, output):
field_to_json(field, newpath, output)


def field_to_json(desc, path, output):
def field_to_json(desc, path, output,
indexed=True, analyzed=False, doc_values=True,
searchable=True, aggregatable=True):

global unique_fields

Expand All @@ -45,11 +47,11 @@ def field_to_json(desc, path, output):
"name": path,
"count": 0,
"scripted": False,
"indexed": True,
"analyzed": False,
"doc_values": True,
"searchable": True,
"aggregatable": True,
"indexed": indexed,
"analyzed": analyzed,
"doc_values": doc_values,
"searchable": searchable,
"aggregatable": aggregatable,
}
# find the kibana types based on the field type
if "type" in desc:
Expand Down Expand Up @@ -93,17 +95,23 @@ def fields_to_index_pattern(args, input):
for k, section in enumerate(docs["fields"]):
fields_to_json(section, "", output)

# add special fields
special_fields = {
"fields": [
{"name": "_index", "type": "text"},
{"name": "_id", "type": "text"},
{"name": "_type", "type": "text"},
{"name": "_score", "type": "integer"}
],
}
# add meta fields

field_to_json({"name": "_id", "type": "keyword"}, "_id", output,
indexed=False, analyzed=False, doc_values=False,
searchable=False, aggregatable=False)

field_to_json({"name": "_type", "type": "keyword"}, "_type", output,
indexed=False, analyzed=False, doc_values=False,
searchable=True, aggregatable=True)

field_to_json({"name": "_index", "type": "keyword"}, "_index", output,
indexed=False, analyzed=False, doc_values=False,
searchable=False, aggregatable=False)

fields_to_json(special_fields, "", output)
field_to_json({"name": "_score", "type": "integer"}, "_score", output,
indexed=False, analyzed=False, doc_values=False,
searchable=False, aggregatable=False)

output["fields"] = json.dumps(output["fields"])
output["fieldFormatMap"] = json.dumps(output["fieldFormatMap"])
Expand Down