ElasticQueryAdapter: Move isV6 method to ElasticVersion and simplify
Move isV6 to ElasticVersion and simplify it to make it work with all future 6.x versions, ratehr than being hard-coded to 6.2 and 6.3. Add a test. Change-Id: Ibd17a45ebbcbbc8edcd37c8aec37090d878ebdf4
This commit is contained in:
@@ -31,8 +31,8 @@ public class ElasticQueryAdapter {
|
|||||||
|
|
||||||
ElasticQueryAdapter(ElasticVersion version) {
|
ElasticQueryAdapter(ElasticVersion version) {
|
||||||
this.ignoreUnmapped = version == ElasticVersion.V2_4;
|
this.ignoreUnmapped = version == ElasticVersion.V2_4;
|
||||||
this.usePostV5Type = isV6(version);
|
this.usePostV5Type = version.isV6();
|
||||||
this.versionDiscoveryUrl = isV6(version) ? "%s*" : "%s*/_aliases";
|
this.versionDiscoveryUrl = version.isV6() ? "%s*" : "%s*/_aliases";
|
||||||
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case V5_6:
|
case V5_6:
|
||||||
@@ -55,10 +55,6 @@ public class ElasticQueryAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isV6(ElasticVersion version) {
|
|
||||||
return version == ElasticVersion.V6_2 || version == ElasticVersion.V6_3;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIgnoreUnmapped(JsonObject properties) {
|
void setIgnoreUnmapped(JsonObject properties) {
|
||||||
if (ignoreUnmapped) {
|
if (ignoreUnmapped) {
|
||||||
properties.addProperty("ignore_unmapped", true);
|
properties.addProperty("ignore_unmapped", true);
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ public enum ElasticVersion {
|
|||||||
return Joiner.on(", ").join(ElasticVersion.values());
|
return Joiner.on(", ").join(ElasticVersion.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isV6() {
|
||||||
|
return version.startsWith("6.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return version;
|
return version;
|
||||||
|
|||||||
@@ -46,4 +46,11 @@ public class ElasticVersionTest {
|
|||||||
"Invalid version: [4.0.0]. Supported versions: " + ElasticVersion.supportedVersions());
|
"Invalid version: [4.0.0]. Supported versions: " + ElasticVersion.supportedVersions());
|
||||||
ElasticVersion.forVersion("4.0.0");
|
ElasticVersion.forVersion("4.0.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void version6() throws Exception {
|
||||||
|
assertThat(ElasticVersion.V6_2.isV6()).isTrue();
|
||||||
|
assertThat(ElasticVersion.V6_3.isV6()).isTrue();
|
||||||
|
assertThat(ElasticVersion.V5_6.isV6()).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user