From 0fefc695063e4f051363e2a2439e56420283bb26 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Tue, 7 Dec 2021 13:30:43 -0800 Subject: [PATCH 1/4] Add a geoshape field to the scripting fields api --- .../AbstractAtomicGeoShapeShapeFieldData.java | 62 +-------- .../GeoShapeWithDocValuesFieldMapper.java | 129 ++++++++++++++++-- 2 files changed, 125 insertions(+), 66 deletions(-) diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java index 0c838f383e9c2..d90edb28f08f1 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.geo.GeoBoundingBox; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.index.fielddata.ScriptDocValues; +import org.elasticsearch.index.fielddata.ScriptDocValues.GeometrySupplier; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; import org.elasticsearch.script.field.DocValuesField; import org.elasticsearch.script.field.ToScriptField; @@ -18,7 +19,6 @@ import org.elasticsearch.xpack.spatial.index.fielddata.GeoShapeValues.GeoShapeValue; import org.elasticsearch.xpack.spatial.index.fielddata.LeafGeoShapeFieldData; -import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -66,71 +66,23 @@ public GeoShapeValues getGeoShapeValues() { }; } - public static final class GeoShapeSupplier implements ScriptDocValues.GeometrySupplier { - - private final GeoShapeValues in; - private final GeoPoint centroid = new GeoPoint(); - private final GeoBoundingBox boundingBox = new GeoBoundingBox(new GeoPoint(), new GeoPoint()); - private GeoShapeValues.GeoShapeValue value; - - public GeoShapeSupplier(GeoShapeValues in) { - this.in = in; - } - - @Override - public void setNextDocId(int docId) throws IOException { - if (in.advanceExact(docId)) { - value = in.value(); - centroid.reset(value.lat(), value.lon()); - boundingBox.topLeft().reset(value.boundingBox().maxY(), value.boundingBox().minX()); - boundingBox.bottomRight().reset(value.boundingBox().minY(), value.boundingBox().maxX()); - } else { - value = null; - } - } - - @Override - public GeoShapeValue getInternal(int index) { - throw new UnsupportedOperationException(); - } - - public GeoShapeValue getInternal() { - return value; - } - - @Override - public int size() { - return value == null ? 0 : 1; - } - - @Override - public GeoPoint getInternalCentroid() { - return centroid; - } - - @Override - public GeoBoundingBox getInternalBoundingBox() { - return boundingBox; - } - } - public static final class GeoShapeScriptValues extends ScriptDocValues.Geometry { - private final GeoShapeSupplier gsSupplier; + private final GeometrySupplier gsSupplier; - public GeoShapeScriptValues(GeoShapeSupplier supplier) { + public GeoShapeScriptValues(GeometrySupplier supplier) { super(supplier); this.gsSupplier = supplier; } @Override public int getDimensionalType() { - return gsSupplier.getInternal() == null ? -1 : gsSupplier.getInternal().dimensionalShapeType().ordinal(); + return gsSupplier.getInternal(0) == null ? -1 : gsSupplier.getInternal(0).dimensionalShapeType().ordinal(); } @Override public GeoPoint getCentroid() { - return gsSupplier.getInternal() == null ? null : gsSupplier.getInternalCentroid(); + return gsSupplier.getInternal(0) == null ? null : gsSupplier.getInternalCentroid(); } @Override @@ -145,12 +97,12 @@ public double getMercatorHeight() { @Override public GeoBoundingBox getBoundingBox() { - return gsSupplier.getInternal() == null ? null : gsSupplier.getInternalBoundingBox(); + return gsSupplier.getInternal(0) == null ? null : gsSupplier.getInternalBoundingBox(); } @Override public GeoShapeValues.GeoShapeValue get(int index) { - return gsSupplier.getInternal(); + return gsSupplier.getInternal(0); } @Override diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java index eab5e5c41b2fe..1cd27a07a5396 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java @@ -15,7 +15,9 @@ import org.apache.lucene.search.Query; import org.elasticsearch.Version; import org.elasticsearch.common.Explicit; +import org.elasticsearch.common.geo.GeoBoundingBox; import org.elasticsearch.common.geo.GeoFormatterFactory; +import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoShapeUtils; import org.elasticsearch.common.geo.GeometryParser; import org.elasticsearch.common.geo.Orientation; @@ -24,6 +26,7 @@ import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.geometry.Geometry; import org.elasticsearch.index.fielddata.IndexFieldData; +import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.mapper.AbstractShapeGeometryFieldMapper; import org.elasticsearch.index.mapper.DocumentParserContext; import org.elasticsearch.index.mapper.FieldMapper; @@ -39,16 +42,19 @@ import org.elasticsearch.index.query.QueryShardException; import org.elasticsearch.index.query.SearchExecutionContext; import org.elasticsearch.legacygeo.mapper.LegacyGeoShapeFieldMapper; -import org.elasticsearch.script.field.DelegateDocValuesField; +import org.elasticsearch.script.field.DocValuesField; import org.elasticsearch.search.lookup.SearchLookup; +import org.elasticsearch.xpack.spatial.index.fielddata.GeoShapeValues; import org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractAtomicGeoShapeShapeFieldData; import org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData; import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType; import java.io.IOException; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; @@ -175,16 +181,7 @@ public GeoShapeWithDocValuesFieldType( public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { failIfNoDocValues(); - return new AbstractLatLonShapeIndexFieldData.Builder( - name(), - GeoShapeValuesSourceType.instance(), - (dv, n) -> new DelegateDocValuesField( - new AbstractAtomicGeoShapeShapeFieldData.GeoShapeScriptValues( - new AbstractAtomicGeoShapeShapeFieldData.GeoShapeSupplier(dv) - ), - n - ) - ); + return new AbstractLatLonShapeIndexFieldData.Builder(name(), GeoShapeValuesSourceType.instance(), GeoShapeDocValuesField::new); } @Override @@ -344,4 +341,114 @@ protected void checkIncomingMergeType(FieldMapper mergeWith) { } super.checkIncomingMergeType(mergeWith); } + + public static class GeoShapeDocValuesField + implements + DocValuesField, + ScriptDocValues.GeometrySupplier { + + private final GeoShapeValues in; + protected final String name; + + private GeoShapeValues.GeoShapeValue value; + + // maintain bwc by making bounding box and centroid available to GeoShapeValues (ScriptDocValues) + private final GeoPoint centroid = new GeoPoint(); + private final GeoBoundingBox boundingBox = new GeoBoundingBox(new GeoPoint(), new GeoPoint()); + private AbstractAtomicGeoShapeShapeFieldData.GeoShapeScriptValues geoShapeScriptValues; + + public GeoShapeDocValuesField(GeoShapeValues in, String name) { + this.in = in; + this.name = name; + } + + @Override + public void setNextDocId(int docId) throws IOException { + if (in.advanceExact(docId)) { + value = in.value(); + centroid.reset(value.lat(), value.lon()); + boundingBox.topLeft().reset(value.boundingBox().maxY(), value.boundingBox().minX()); + boundingBox.bottomRight().reset(value.boundingBox().minY(), value.boundingBox().maxX()); + } else { + value = null; + } + } + + @Override + public ScriptDocValues getScriptDocValues() { + if (geoShapeScriptValues == null) { + geoShapeScriptValues = new AbstractAtomicGeoShapeShapeFieldData.GeoShapeScriptValues(this); + } + + return geoShapeScriptValues; + } + + @Override + public GeoShapeValues.GeoShapeValue getInternal(int index) { + if (index != 0) { + throw new UnsupportedOperationException(); + } + + return value; + } + + // maintain bwc by making centroid available to GeoShapeValues (ScriptDocValues) + @Override + public GeoPoint getInternalCentroid() { + return centroid; + } + + // maintain bwc by making centroid available to GeoShapeValues (ScriptDocValues) + @Override + public GeoBoundingBox getInternalBoundingBox() { + return boundingBox; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean isEmpty() { + return value != null; + } + + @Override + public int size() { + return value == null ? 0 : 1; + } + + public GeoShapeValues.GeoShapeValue get(GeoShapeValues.GeoShapeValue defaultValue) { + return get(0, defaultValue); + } + + public GeoShapeValues.GeoShapeValue get(int index, GeoShapeValues.GeoShapeValue defaultValue) { + if (isEmpty() || index != 0) { + return defaultValue; + } + + return value; + } + + @Override + public Iterator iterator() { + return new Iterator() { + private int index = 0; + + @Override + public boolean hasNext() { + return index < size(); + } + + @Override + public GeoShapeValues.GeoShapeValue next() { + if (hasNext() == false) { + throw new NoSuchElementException(); + } + return value; + } + }; + } + } } From 40e95e3278a12512fa49f222f619fe84dba88646 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Tue, 7 Dec 2021 16:53:12 -0800 Subject: [PATCH 2/4] add skeleton for painless allow list --- x-pack/plugin/spatial/build.gradle | 3 +- .../spatial/SpatialPainlessExtension.java | 36 +++++++++++++++++++ .../AbstractAtomicGeoShapeShapeFieldData.java | 4 +++ ...asticsearch.painless.spi.PainlessExtension | 1 + ...ch.xpack.spatial.index.fielddata.plain.txt | 4 +++ ...icsearch.xpack.spatial.index.fielddata.txt | 3 ++ 6 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java create mode 100644 x-pack/plugin/spatial/src/main/resources/META-INF/services/org.elasticsearch.painless.spi.PainlessExtension create mode 100644 x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt create mode 100644 x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt diff --git a/x-pack/plugin/spatial/build.gradle b/x-pack/plugin/spatial/build.gradle index ffbfdff0cc1bb..f0fac40a292b8 100644 --- a/x-pack/plugin/spatial/build.gradle +++ b/x-pack/plugin/spatial/build.gradle @@ -7,11 +7,12 @@ esplugin { name 'spatial' description 'A plugin for Basic Spatial features' classname 'org.elasticsearch.xpack.spatial.SpatialPlugin' - extendedPlugins = ['x-pack-core', 'legacy-geo'] + extendedPlugins = ['x-pack-core', 'legacy-geo', 'lang-painless'] } dependencies { compileOnly project(path: ':modules:legacy-geo') + compileOnly project(':modules:lang-painless:spi') compileOnly project(path: xpackModule('core')) testImplementation(testArtifact(project(xpackModule('core')))) testImplementation project(path: xpackModule('vector-tile')) diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java new file mode 100644 index 0000000000000..4dce32daa28d1 --- /dev/null +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java @@ -0,0 +1,36 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.spatial; + +import org.elasticsearch.painless.spi.PainlessExtension; +import org.elasticsearch.painless.spi.Whitelist; +import org.elasticsearch.painless.spi.WhitelistLoader; +import org.elasticsearch.script.ScriptContext; +import org.elasticsearch.script.ScriptModule; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SpatialPainlessExtension implements PainlessExtension { + + private static final List WHITELISTS = List.of( + WhitelistLoader.loadFromResourceFiles(SpatialPainlessExtension.class, "org.elasticsearch.xpack.spatial.index.fielddata.txt") + ); + + @Override + public Map, List> getContextWhitelists() { + Map, List> contextWhitelistMap = new HashMap<>(); + + for (ScriptContext context : ScriptModule.CORE_CONTEXTS.values()) { + contextWhitelistMap.put(context, WHITELISTS); + } + + return contextWhitelistMap; + } +} diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java index d90edb28f08f1..9a8e8ff48c2fd 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/plain/AbstractAtomicGeoShapeShapeFieldData.java @@ -105,6 +105,10 @@ public GeoShapeValues.GeoShapeValue get(int index) { return gsSupplier.getInternal(0); } + public GeoShapeValues.GeoShapeValue getValue() { + return gsSupplier.getInternal(0); + } + @Override public int size() { return supplier.size(); diff --git a/x-pack/plugin/spatial/src/main/resources/META-INF/services/org.elasticsearch.painless.spi.PainlessExtension b/x-pack/plugin/spatial/src/main/resources/META-INF/services/org.elasticsearch.painless.spi.PainlessExtension new file mode 100644 index 0000000000000..0c64dd8523a3f --- /dev/null +++ b/x-pack/plugin/spatial/src/main/resources/META-INF/services/org.elasticsearch.painless.spi.PainlessExtension @@ -0,0 +1 @@ +org.elasticsearch.xpack.spatial.SpatialPainlessExtension diff --git a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt new file mode 100644 index 0000000000000..fbc1e6f1c8962 --- /dev/null +++ b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt @@ -0,0 +1,4 @@ +class org.elasticsearch.xpack.spatial.fielddata.plain.AbstractAtomicGeoShapeShapeFieldData$GeoShapeScriptValues { + GeoShapeValues$GeoShapeValue get(int) + GeoShapeValues$GeoShapeValue getValue() +} diff --git a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt new file mode 100644 index 0000000000000..a3c32ade00551 --- /dev/null +++ b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt @@ -0,0 +1,3 @@ +class org.elasticsearch.xpack.spatial.index.fielddata.GeoShapeValues$GeoShapeValue { + +} From cb085cba7c5a1c75129d188daaa011e56562e192 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Thu, 9 Dec 2021 16:04:29 -0800 Subject: [PATCH 3/4] add tests --- .../spatial/SpatialPainlessExtension.java | 7 +++++- .../GeoShapeWithDocValuesFieldMapper.java | 2 +- ...ch.xpack.spatial.index.fielddata.plain.txt | 6 ++--- ...icsearch.xpack.spatial.index.fielddata.txt | 1 - ...asticsearch.xpack.spatial.index.mapper.txt | 4 ++++ .../test/70_script_doc_values.yml | 24 +++++++++++++++++++ 6 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.mapper.txt diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java index 4dce32daa28d1..7aba3d06c2527 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/SpatialPainlessExtension.java @@ -20,7 +20,12 @@ public class SpatialPainlessExtension implements PainlessExtension { private static final List WHITELISTS = List.of( - WhitelistLoader.loadFromResourceFiles(SpatialPainlessExtension.class, "org.elasticsearch.xpack.spatial.index.fielddata.txt") + WhitelistLoader.loadFromResourceFiles( + SpatialPainlessExtension.class, + "org.elasticsearch.xpack.spatial.index.fielddata.txt", + "org.elasticsearch.xpack.spatial.index.fielddata.plain.txt", + "org.elasticsearch.xpack.spatial.index.mapper.txt" + ) ); @Override diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java index 1cd27a07a5396..20fefb5baa82d 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java @@ -411,7 +411,7 @@ public String getName() { @Override public boolean isEmpty() { - return value != null; + return value == null; } @Override diff --git a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt index fbc1e6f1c8962..4e66142f293c6 100644 --- a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt +++ b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.plain.txt @@ -1,4 +1,4 @@ -class org.elasticsearch.xpack.spatial.fielddata.plain.AbstractAtomicGeoShapeShapeFieldData$GeoShapeScriptValues { - GeoShapeValues$GeoShapeValue get(int) - GeoShapeValues$GeoShapeValue getValue() +class org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractAtomicGeoShapeShapeFieldData$GeoShapeScriptValues { + GeoShapeValues.GeoShapeValue get(int) + GeoShapeValues.GeoShapeValue getValue() } diff --git a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt index a3c32ade00551..2f906b0821d1a 100644 --- a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt +++ b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.fielddata.txt @@ -1,3 +1,2 @@ class org.elasticsearch.xpack.spatial.index.fielddata.GeoShapeValues$GeoShapeValue { - } diff --git a/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.mapper.txt b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.mapper.txt new file mode 100644 index 0000000000000..0e0ec95dbecb5 --- /dev/null +++ b/x-pack/plugin/spatial/src/main/resources/org/elasticsearch/xpack/spatial/org.elasticsearch.xpack.spatial.index.mapper.txt @@ -0,0 +1,4 @@ +class org.elasticsearch.xpack.spatial.index.mapper.GeoShapeWithDocValuesFieldMapper$GeoShapeDocValuesField { + GeoShapeValues.GeoShapeValue get(GeoShapeValues.GeoShapeValue) + GeoShapeValues.GeoShapeValue get(int, GeoShapeValues.GeoShapeValue) +} diff --git a/x-pack/plugin/spatial/src/yamlRestTest/resources/rest-api-spec/test/70_script_doc_values.yml b/x-pack/plugin/spatial/src/yamlRestTest/resources/rest-api-spec/test/70_script_doc_values.yml index 482eb1661fcdb..3831268c4f783 100644 --- a/x-pack/plugin/spatial/src/yamlRestTest/resources/rest-api-spec/test/70_script_doc_values.yml +++ b/x-pack/plugin/spatial/src/yamlRestTest/resources/rest-api-spec/test/70_script_doc_values.yml @@ -92,6 +92,30 @@ setup: - match: { error.root_cause.0.reason: "cannot write xcontent for geo_shape doc value" } + - do: + catch: /illegal_argument_exception/ + search: + rest_total_hits_as_int: true + body: + script_fields: + type: + script: + source: "field('geo_shape').get(null)" + + - match: { error.root_cause.0.reason: "cannot write xcontent for geo_shape doc value" } + + - do: + catch: /illegal_argument_exception/ + search: + rest_total_hits_as_int: true + body: + script_fields: + type: + script: + source: "/* avoid yaml stash */ $('geo_shape', null)" + + - match: { error.root_cause.0.reason: "cannot write xcontent for geo_shape doc value" } + --- "diagonal length": - do: From 0ee29cececb51e6786cba6be438edb5542cf6d48 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Thu, 9 Dec 2021 16:20:32 -0800 Subject: [PATCH 4/4] Update docs/changelog/81617.yaml --- docs/changelog/81617.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/81617.yaml diff --git a/docs/changelog/81617.yaml b/docs/changelog/81617.yaml new file mode 100644 index 0000000000000..f2873ab52562a --- /dev/null +++ b/docs/changelog/81617.yaml @@ -0,0 +1,5 @@ +pr: 81617 +summary: Add support for `GeoShape` to the scripting fields API +area: Infra/Scripting +type: enhancement +issues: []