-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
disallow creating geo_shape mappings with deprecated parameters #70850
Changes from 2 commits
edfd032
40ad9bc
d707cf0
ab9063e
82995d1
4b4a5e3
44edae5
1b5ecf8
ff7fd85
6d66d6a
e93344b
4f3a451
75b827d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree; | ||
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree; | ||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.CheckedConsumer; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.geo.GeoUtils; | ||
|
@@ -25,6 +26,7 @@ | |
import org.elasticsearch.index.query.SearchExecutionContext; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; | ||
import org.elasticsearch.test.VersionUtils; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
|
@@ -98,6 +100,24 @@ protected boolean supportsMeta() { | |
return false; | ||
} | ||
|
||
@Override | ||
protected MapperService createMapperService(XContentBuilder mappings) throws IOException { | ||
Version version = VersionUtils.randomPreviousCompatibleVersion(random(), Version.V_8_0_0); | ||
return createMapperService(version, mappings); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about we also override There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works too. Implemented. |
||
|
||
public void testInvalidCurrentVersion() { | ||
MapperParsingException e = | ||
expectThrows(MapperParsingException.class, | ||
() -> createMapperService(Version.CURRENT, fieldMapping((b) -> { | ||
b.field("type", "geo_shape").field("strategy", "recursive").field("points_only", true); | ||
}))); | ||
assertThat(e.getMessage(), | ||
containsString("using deprecated parameters [points_only, strategy] " + | ||
"in mapper [field] of type [geo_shape] is no longer allowed")); | ||
assertFieldWarnings(new String[] {"points_only", "strategy"}); | ||
} | ||
|
||
public void testLegacySwitches() throws IOException { | ||
// if one of the legacy parameters is added to a 'type':'geo_shape' config then | ||
// that will select the legacy field mapper | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this into the Builder constructor? The earlier we throw the better, in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried but I have issues with this test:
elasticsearch/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java
Line 270 in 91c700b
It seems that checking of unknown parameters happen after the builder.