Skip to content

Commit

Permalink
Use race-timestamp in annotations
Browse files Browse the repository at this point in the history
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 elastic#128
Relates elastic#143
  • Loading branch information
danielmitterdorfer committed Nov 19, 2019
1 parent 75ae94e commit e589317
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions night_rally/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions night_rally/resources/annotation-mapping.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"type": {
"_all": {
"enabled": false
},
"_doc": {
"dynamic_templates": [
{
"strings": {
Expand All @@ -19,7 +19,7 @@
"environment": {
"type": "keyword"
},
"trial-timestamp": {
"race-timestamp": {
"type": "date",
"fields": {
"raw": {
Expand Down

0 comments on commit e589317

Please sign in to comment.