Skip to content

Commit

Permalink
Set options for _index, _id, _type, _score similar with the ones set …
Browse files Browse the repository at this point in the history
…by Kibana (#3284)
  • Loading branch information
monicasarbu authored and ruflin committed Jan 5, 2017
1 parent 8b87995 commit 1785b47
Showing 1 changed file with 24 additions and 16 deletions.
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

0 comments on commit 1785b47

Please sign in to comment.