Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bwc in GeoDistanceQuery serialization #29325

Merged
merged 2 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions qa/rolling-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ for (Version version : bwcVersions.wireCompatible) {
numNodes = 2
clusterName = 'rolling-upgrade'
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
setting 'node.attr.gen', 'old'
if (version.onOrAfter('5.3.0')) {
setting 'http.content_type.required', 'true'
}
Expand All @@ -64,6 +65,7 @@ for (Version version : bwcVersions.wireCompatible) {
* just stopped's data directory. */
dataDir = { nodeNumber -> oldClusterTest.nodes[1].dataDir }
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
setting 'node.attr.gen', 'new'
}

Task mixedClusterTestRunner = tasks.getByName("${baseName}#mixedClusterTestRunner")
Expand All @@ -83,6 +85,7 @@ for (Version version : bwcVersions.wireCompatible) {
* just stopped's data directory. */
dataDir = { nodeNumber -> oldClusterTest.nodes[0].dataDir}
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
setting 'node.attr.gen', 'new'
}

Task upgradedClusterTestRunner = tasks.getByName("${baseName}#upgradedClusterTestRunner")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,48 @@ public void testRelocationWithConcurrentIndexing() throws Exception {
}
}

public void testSearchGeoPoints() throws Exception {
final String index = "geo_index";
if (clusterType == CLUSTER_TYPE.OLD) {
Settings.Builder settings = Settings.builder()
.put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1)
.put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1)
// if the node with the replica is the first to be restarted, while a replica is still recovering
// then delayed allocation will kick in. When the node comes back, the master will search for a copy
// but the recovering copy will be seen as invalid and the cluster health won't return to GREEN
// before timing out
.put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms");
createIndex(index, settings.build(), "\"doc\": {\"properties\": {\"location\": {\"type\": \"geo_point\"}}}");
ensureGreen(index);
} else if (clusterType == CLUSTER_TYPE.MIXED) {
ensureGreen(index);
String requestBody = "{\n" +
" \"query\": {\n" +
" \"bool\": {\n" +
" \"should\": [\n" +
" {\n" +
" \"geo_distance\": {\n" +
" \"distance\": \"1000km\",\n" +
" \"location\": {\n" +
" \"lat\": 40,\n" +
" \"lon\": -70\n" +
" }\n" +
" }\n" +
" },\n" +
" {\"match_all\": {}}\n" +
" ]\n" +
" }\n" +
" }\n" +
"}";

// we need to make sure that requests are routed from a new node to the old node so we are sending the request a few times
for (int i = 0; i < 10; i++) {
Response response = client().performRequest("GET", index + "/_search",
Collections.singletonMap("preference", "_only_nodes:gen:old"), // Make sure we only send this request to old nodes
new StringEntity(requestBody, ContentType.APPLICATION_JSON));
assertOK(response);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.lucene.search.IndexOrDocValuesQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -97,6 +98,10 @@ public GeoDistanceQueryBuilder(StreamInput in) throws IOException {
distance = in.readDouble();
validationMethod = GeoValidationMethod.readFromStream(in);
center = in.readGeoPoint();
if (in.getVersion().before(Version.V_6_0_0_alpha1)) {
// optimize bounding box was removed in 6.0
in.readOptionalString();
}
geoDistance = GeoDistance.readFromStream(in);
ignoreUnmapped = in.readBoolean();
}
Expand All @@ -107,6 +112,10 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeDouble(distance);
validationMethod.writeTo(out);
out.writeGeoPoint(center);
if (out.getVersion().before(Version.V_6_0_0_alpha1)) {
// optimize bounding box was removed in 6.0
out.writeOptionalString(null);
}
geoDistance.writeTo(out);
out.writeBoolean(ignoreUnmapped);
}
Expand Down