diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTags.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTags.java index b9a5ea92c7f..8229e84b9f8 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTags.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTags.java @@ -57,11 +57,11 @@ final class ElasticsearchAutocompleteTags implements AutocompleteTags { if (indices.isEmpty()) return Call.emptyList(); SearchRequest.Filters filters = - new SearchRequest.Filters().addTerm("tagkey", key.toLowerCase(Locale.ROOT)); + new SearchRequest.Filters().addTerm("tagKey", key.toLowerCase(Locale.ROOT)); SearchRequest request = SearchRequest.create(indices) .filters(filters) - .addAggregation(Aggregation.terms("tagvalue", Integer.MAX_VALUE)); + .addAggregation(Aggregation.terms("tagValue", Integer.MAX_VALUE)); return search.newCall(request, BodyConverters.KEYS); } } diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchSpanConsumer.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchSpanConsumer.java index 41c45c4912f..611bc06114e 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchSpanConsumer.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchSpanConsumer.java @@ -108,9 +108,9 @@ void addTag(long indexTimestamp, Span span) { JsonWriter writer = JsonWriter.of(query); writer.beginObject(); - writer.name("tagkey"); + writer.name("tagKey"); writer.value(tag.getKey()); - writer.name("tagvalue"); + writer.name("tagValue"); writer.value(tag.getValue()); writer.endObject(); String index = indexNameFormatter.formatTypeAndTimestamp(AUTOCOMPLETE, indexTimestamp); diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java index 1bc88a13ffe..20130345c07 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/ElasticsearchStorage.java @@ -337,7 +337,7 @@ IndexTemplates ensureIndexTemplates() { EnsureIndexTemplate.apply( http(), index + ":" + DEPENDENCY + "_template", templates.dependency()); EnsureIndexTemplate.apply( - http(), index + ":" + AUTOCOMPLETE + "_template", templates.tag()); + http(), index + ":" + AUTOCOMPLETE + "_template", templates.autocomplete()); return templates; } catch (IOException e) { throw Platform.get().uncheckedIOException(e); diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/IndexTemplates.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/IndexTemplates.java index 0c274462836..a998dde7ce7 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/IndexTemplates.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/IndexTemplates.java @@ -27,7 +27,7 @@ static Builder newBuilder() { abstract String dependency(); - abstract String tag(); + abstract String autocomplete(); @AutoValue.Builder interface Builder { @@ -37,7 +37,7 @@ interface Builder { Builder dependency(String dependency); - Builder tag(String tag); + Builder autocomplete(String autocomplete); IndexTemplates build(); } diff --git a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java index 9479f377d52..7d6b5c1696e 100644 --- a/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java +++ b/zipkin-storage/elasticsearch/src/main/java/zipkin2/elasticsearch/VersionSpecificTemplates.java @@ -32,7 +32,7 @@ final class VersionSpecificTemplates { final boolean searchEnabled; final String spanIndexTemplate; final String dependencyIndexTemplate; - final String tagIndexTemplate; + final String autocompleteIndexTemplate; VersionSpecificTemplates(ElasticsearchStorage es) { this.searchEnabled = es.searchEnabled(); @@ -51,7 +51,7 @@ final class VersionSpecificTemplates { .replace("${__INDEX__}", es.indexNameFormatter().index()) .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(es.indexReplicas())); - this.tagIndexTemplate = TAG_INDEX_TEMPLATE + this.autocompleteIndexTemplate = AUTOCOMPLETE_INDEX_TEMPLATE .replace("${__INDEX__}", es.indexNameFormatter().index()) .replace("${__NUMBER_OF_SHARDS__}", String.valueOf(es.indexShards())) .replace("${__NUMBER_OF_REPLICAS__}", String.valueOf(es.indexReplicas())); @@ -167,9 +167,9 @@ String spanIndexTemplate() { + "\": { \"enabled\": false }}\n" + "}"; - // The key filed of a autocompleteKeys is intentionally names as tagkey since it clashes with the + // The key filed of a autocompleteKeys is intentionally names as tagKey since it clashes with the // BodyConverters KEY - static final String TAG_INDEX_TEMPLATE = + static final String AUTOCOMPLETE_INDEX_TEMPLATE = "{\n" + " \"TEMPLATE\": \"${__INDEX__}:" + AUTOCOMPLETE @@ -184,8 +184,8 @@ String spanIndexTemplate() { + AUTOCOMPLETE + "\": { \"enabled\": true,\n" + " \t\"properties\": {\n" - + " \"tagkey\": { KEYWORD },\n" - + " \"tagvalue\": { KEYWORD }\n" + + " \"tagKey\": { KEYWORD },\n" + + " \"tagValue\": { KEYWORD }\n" + " }}}\n" + "}"; IndexTemplates get(HttpCall.Factory callFactory) throws IOException { @@ -194,7 +194,7 @@ IndexTemplates get(HttpCall.Factory callFactory) throws IOException { .version(version) .span(versionSpecificSpanIndexTemplate(version)) .dependency(versionSpecificDependencyLinkIndexTemplate(version)) - .tag(versionSpecificTagIndexTemplate(version)) + .autocomplete(versionSpecificAutocompleteIndexTemplate(version)) .build(); } @@ -252,14 +252,14 @@ private String versionSpecificDependencyLinkIndexTemplate(float version) { return dependencyIndexTemplate.replace( "TEMPLATE", version >= 6 ? "index_patterns" : "template"); } - private String versionSpecificTagIndexTemplate(float version) { + private String versionSpecificAutocompleteIndexTemplate(float version) { if (version >= 2 && version < 3) { - return tagIndexTemplate + return autocompleteIndexTemplate .replace("TEMPLATE", "template") .replace("KEYWORD", "\"type\": \"string\", \"norms\": {\"enabled\": false }, \"index\": " + "\"not_analyzed\""); } else if (version >= 5) { - return tagIndexTemplate + return autocompleteIndexTemplate .replace("TEMPLATE", version >= 6 ? "index_patterns" : "template") .replace("KEYWORD", "\"type\": \"text\",\"fielddata\": true\n"); }else { diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTagsTest.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTagsTest.java index ee14f6d52c8..c1f0f871505 100644 --- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTagsTest.java +++ b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/ElasticsearchAutocompleteTagsTest.java @@ -43,7 +43,7 @@ public class ElasticsearchAutocompleteTagsTest { @Test public void getValues_requestIncludesKeyName() throws Exception { es.enqueue(new MockResponse().setBody(TestResponses.AUTOCOMPLETE_VALUES)); tagStore.getValues("http.method").execute(); - assertThat(es.takeRequest().getBody().readUtf8()).contains("\"tagkey\":\"http.method\""); + assertThat(es.takeRequest().getBody().readUtf8()).contains("\"tagKey\":\"http.method\""); } @Test public void getValues() throws Exception { diff --git a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/TestResponses.java b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/TestResponses.java index db905972f37..95fb8d09bb4 100644 --- a/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/TestResponses.java +++ b/zipkin-storage/elasticsearch/src/test/java/zipkin2/elasticsearch/TestResponses.java @@ -118,7 +118,7 @@ public final class TestResponses { + " ]\n" + " },\n" + " \"aggregations\": {\n" - + " \"tagvalue\": {\n" + + " \"tagValue\": {\n" + " \"doc_count_error_upper_bound\": 0,\n" + " \"sum_other_doc_count\": 0,\n" + " \"buckets\": [\n"