Skip to content

Commit

Permalink
Aligns naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed Jan 3, 2019
1 parent e959e67 commit 7d34956
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static Builder newBuilder() {

abstract String dependency();

abstract String tag();
abstract String autocomplete();

@AutoValue.Builder
interface Builder {
Expand All @@ -37,7 +37,7 @@ interface Builder {

Builder dependency(String dependency);

Builder tag(String tag);
Builder autocomplete(String autocomplete);

IndexTemplates build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()));
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7d34956

Please sign in to comment.