From e589317a790812dc45f4c8416880910295f404e7 Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Tue, 19 Nov 2019 09:00:12 -0500 Subject: [PATCH] Use race-timestamp in annotations With this commit we change the annotation mapping to use the new field `race-timestamp` instead of the previous field `trial-timestamp` so it matches documents in `rally-results-*` again. We also remove any incompatibilies for newer versions of Elasticsearch (`_all` field, document type is `_doc` now). Relates #128 Relates #143 --- night_rally/admin.py | 7 ++++--- night_rally/resources/annotation-mapping.json | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/night_rally/admin.py b/night_rally/admin.py index 3d8c6f2e9a425..3d7eee5c319db 100644 --- a/night_rally/admin.py +++ b/night_rally/admin.py @@ -165,9 +165,10 @@ def add_annotation(es, args): (message, environment, trial_timestamp, track, chart)) else: if not es.indices.exists(index="rally-annotations"): - body = open("%s/resources/annotation-mapping.json" % os.path.dirname(os.path.realpath(__file__)), "rt").read() + cwd = os.path.dirname(os.path.realpath(__file__)) + body = open(os.path.join(cwd, "resources", "annotation-mapping.json"), "rt").read() es.indices.create(index="rally-annotations", body=body) - es.index(index="rally-annotations", doc_type="type", body={ + es.index(index="rally-annotations", doc_type="_doc", body={ "environment": environment, "trial-timestamp": trial_timestamp, "track": track, @@ -187,7 +188,7 @@ def delete_annotation(es, args): else: for annotation_id in annotations: try: - es.delete(index="rally-annotations", doc_type="type", id=annotation_id) + es.delete(index="rally-annotations", doc_type="_doc", id=annotation_id) print("Successfully deleted [%s]." % annotation_id) except elasticsearch.TransportError as e: if e.status_code == 404: diff --git a/night_rally/resources/annotation-mapping.json b/night_rally/resources/annotation-mapping.json index a0e3aca4f6aaa..3880a9eed9c80 100644 --- a/night_rally/resources/annotation-mapping.json +++ b/night_rally/resources/annotation-mapping.json @@ -1,9 +1,9 @@ { + "settings": { + "number_of_shards": 1 + }, "mappings": { - "type": { - "_all": { - "enabled": false - }, + "_doc": { "dynamic_templates": [ { "strings": { @@ -19,7 +19,7 @@ "environment": { "type": "keyword" }, - "trial-timestamp": { + "race-timestamp": { "type": "date", "fields": { "raw": {