Fix GeoHash PrefixTree BWC (#38584)
geo_shape indexes created before 6.6 use geohash string encoding as default tree parameter and quadtree encoding for 6.6 and later. This commit fixes bwc to use geohash encoding in LegacyGeoshapeFieldMapper for indexes created before 6.6.
This commit is contained in:
parent
d1848b96fc
commit
078da6d9bd
|
@ -201,13 +201,15 @@ public class LegacyGeoShapeFieldMapper extends BaseGeoShapeFieldMapper {
|
||||||
return (GeoShapeFieldType)fieldType;
|
return (GeoShapeFieldType)fieldType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupFieldTypeDeprecatedParameters() {
|
private void setupFieldTypeDeprecatedParameters(BuilderContext context) {
|
||||||
GeoShapeFieldType ft = fieldType();
|
GeoShapeFieldType ft = fieldType();
|
||||||
if (deprecatedParameters.strategy != null) {
|
if (deprecatedParameters.strategy != null) {
|
||||||
ft.setStrategy(deprecatedParameters.strategy);
|
ft.setStrategy(deprecatedParameters.strategy);
|
||||||
}
|
}
|
||||||
if (deprecatedParameters.tree != null) {
|
if (deprecatedParameters.tree != null) {
|
||||||
ft.setTree(deprecatedParameters.tree);
|
ft.setTree(deprecatedParameters.tree);
|
||||||
|
} else if (context.indexCreatedVersion().before(Version.V_6_6_0)) {
|
||||||
|
ft.setTree(DeprecatedParameters.PrefixTrees.GEOHASH);
|
||||||
}
|
}
|
||||||
if (deprecatedParameters.treeLevels != null) {
|
if (deprecatedParameters.treeLevels != null) {
|
||||||
ft.setTreeLevels(deprecatedParameters.treeLevels);
|
ft.setTreeLevels(deprecatedParameters.treeLevels);
|
||||||
|
@ -275,7 +277,7 @@ public class LegacyGeoShapeFieldMapper extends BaseGeoShapeFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup the deprecated parameters and the prefix tree configuration
|
// setup the deprecated parameters and the prefix tree configuration
|
||||||
setupFieldTypeDeprecatedParameters();
|
setupFieldTypeDeprecatedParameters(context);
|
||||||
setupPrefixTrees();
|
setupPrefixTrees();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +526,9 @@ public class LegacyGeoShapeFieldMapper extends BaseGeoShapeFieldMapper {
|
||||||
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
|
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
|
||||||
super.doXContentBody(builder, includeDefaults, params);
|
super.doXContentBody(builder, includeDefaults, params);
|
||||||
|
|
||||||
if (includeDefaults || fieldType().tree().equals(DeprecatedParameters.Defaults.TREE) == false) {
|
if (includeDefaults
|
||||||
|
|| (fieldType().tree().equals(indexCreatedVersion.onOrAfter(Version.V_6_6_0) ?
|
||||||
|
DeprecatedParameters.Defaults.TREE : DeprecatedParameters.PrefixTrees.GEOHASH)) == false) {
|
||||||
builder.field(DeprecatedParameters.Names.TREE.getPreferredName(), fieldType().tree());
|
builder.field(DeprecatedParameters.Names.TREE.getPreferredName(), fieldType().tree());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue