|
@@ -420,6 +420,40 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
|
|
|
assertEquals(json, 12000.0, parsed.distance(), 0.0001);
|
|
|
}
|
|
|
|
|
|
+ public void testFromCoerceFails() throws IOException {
|
|
|
+ String json =
|
|
|
+ "{\n" +
|
|
|
+ " \"geo_distance\" : {\n" +
|
|
|
+ " \"pin.location\" : [ -70.0, 40.0 ],\n" +
|
|
|
+ " \"distance\" : 12000.0,\n" +
|
|
|
+ " \"distance_type\" : \"sloppy_arc\",\n" +
|
|
|
+ " \"optimize_bbox\" : \"memory\",\n" +
|
|
|
+ " \"coerce\" : true,\n" +
|
|
|
+ " \"ignore_unmapped\" : false,\n" +
|
|
|
+ " \"boost\" : 1.0\n" +
|
|
|
+ " }\n" +
|
|
|
+ "}";
|
|
|
+ IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> parseQuery(json));
|
|
|
+ assertTrue(e.getMessage().startsWith("Deprecated field "));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testFromJsonIgnoreMalformedFails() throws IOException {
|
|
|
+ String json =
|
|
|
+ "{\n" +
|
|
|
+ " \"geo_distance\" : {\n" +
|
|
|
+ " \"pin.location\" : [ -70.0, 40.0 ],\n" +
|
|
|
+ " \"distance\" : 12000.0,\n" +
|
|
|
+ " \"distance_type\" : \"sloppy_arc\",\n" +
|
|
|
+ " \"optimize_bbox\" : \"memory\",\n" +
|
|
|
+ " \"ignore_malformed\" : true,\n" +
|
|
|
+ " \"ignore_unmapped\" : false,\n" +
|
|
|
+ " \"boost\" : 1.0\n" +
|
|
|
+ " }\n" +
|
|
|
+ "}";
|
|
|
+ IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> parseQuery(json));
|
|
|
+ assertTrue(e.getMessage().startsWith("Deprecated field "));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void testMustRewrite() throws IOException {
|
|
|
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
|