From 965d60e1cbdfb9cc97137384bd7ce06478c73654 Mon Sep 17 00:00:00 2001 From: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Date: Tue, 4 Mar 2025 09:58:05 +0100 Subject: [PATCH] geo_grid (#3860) (cherry picked from commit 5b9a58f8c4ed77a65cd85372e383774745caed52) --- output/openapi/elasticsearch-openapi.json | 32 ++++ .../elasticsearch-serverless-openapi.json | 32 ++++ output/schema/schema-serverless.json | 171 +++++++++++++----- output/schema/schema.json | 107 +++++++++-- output/typescript/types.ts | 7 + .../_types/query_dsl/abstractions.ts | 6 + specification/_types/query_dsl/geo.ts | 12 +- 7 files changed, 302 insertions(+), 65 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index fde88f60e4..433f39a862 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -45995,6 +45995,15 @@ "geo_distance": { "$ref": "#/components/schemas/_types.query_dsl:GeoDistanceQuery" }, + "geo_grid": { + "description": "Matches `geo_point` and `geo_shape` values that intersect a grid cell from a GeoGrid aggregation.", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/_types.query_dsl:GeoGridQuery" + }, + "minProperties": 1, + "maxProperties": 1 + }, "geo_polygon": { "$ref": "#/components/schemas/_types.query_dsl:GeoPolygonQuery" }, @@ -47110,6 +47119,29 @@ "plane" ] }, + "_types.query_dsl:GeoGridQuery": { + "allOf": [ + { + "$ref": "#/components/schemas/_types.query_dsl:QueryBase" + }, + { + "type": "object", + "properties": { + "geogrid": { + "$ref": "#/components/schemas/_types:GeoTile" + }, + "geohash": { + "$ref": "#/components/schemas/_types:GeoHash" + }, + "geohex": { + "$ref": "#/components/schemas/_types:GeoHexCell" + } + }, + "minProperties": 1, + "maxProperties": 1 + } + ] + }, "_types.query_dsl:GeoPolygonQuery": { "allOf": [ { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 6945b2f720..7a5e27ebe4 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -26131,6 +26131,15 @@ "geo_distance": { "$ref": "#/components/schemas/_types.query_dsl:GeoDistanceQuery" }, + "geo_grid": { + "description": "Matches `geo_point` and `geo_shape` values that intersect a grid cell from a GeoGrid aggregation.", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/_types.query_dsl:GeoGridQuery" + }, + "minProperties": 1, + "maxProperties": 1 + }, "geo_polygon": { "$ref": "#/components/schemas/_types.query_dsl:GeoPolygonQuery" }, @@ -27246,6 +27255,29 @@ "plane" ] }, + "_types.query_dsl:GeoGridQuery": { + "allOf": [ + { + "$ref": "#/components/schemas/_types.query_dsl:QueryBase" + }, + { + "type": "object", + "properties": { + "geogrid": { + "$ref": "#/components/schemas/_types:GeoTile" + }, + "geohash": { + "$ref": "#/components/schemas/_types:GeoHash" + }, + "geohex": { + "$ref": "#/components/schemas/_types:GeoHexCell" + } + }, + "minProperties": 1, + "maxProperties": 1 + } + ] + }, "_types.query_dsl:GeoPolygonQuery": { "allOf": [ { diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 56d92f1af8..1b0d463b80 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -49128,6 +49128,29 @@ } } }, + { + "description": "Matches `geo_point` and `geo_shape` values that intersect a grid cell from a GeoGrid aggregation.", + "name": "geo_grid", + "required": false, + "type": { + "key": { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + }, + "kind": "dictionary_of", + "singleKey": true, + "value": { + "kind": "instance_of", + "type": { + "name": "GeoGridQuery", + "namespace": "_types.query_dsl" + } + } + } + }, { "deprecation": { "description": "Use geo-shape instead.", @@ -49984,7 +50007,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L102-L428", + "specLocation": "_types/query_dsl/abstractions.ts#L103-L434", "variants": { "kind": "container", "nonExhaustive": true @@ -50163,7 +50186,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L453-L464" + "specLocation": "_types/query_dsl/abstractions.ts#L459-L470" }, { "kind": "type_alias", @@ -50509,7 +50532,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L466-L500" + "specLocation": "_types/query_dsl/abstractions.ts#L472-L506" }, { "kind": "enum", @@ -50525,7 +50548,7 @@ "name": "CombinedFieldsOperator", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/abstractions.ts#L513-L516" + "specLocation": "_types/query_dsl/abstractions.ts#L519-L522" }, { "kind": "enum", @@ -50543,7 +50566,7 @@ "name": "CombinedFieldsZeroTerms", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/abstractions.ts#L518-L527" + "specLocation": "_types/query_dsl/abstractions.ts#L524-L533" }, { "extDocId": "query-dsl-constant-score-query", @@ -52041,7 +52064,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L32-L54" + "specLocation": "_types/query_dsl/geo.ts#L35-L57" }, { "codegenNames": [ @@ -52365,7 +52388,7 @@ "name": "GeoExecution", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/geo.ts#L56-L59" + "specLocation": "_types/query_dsl/geo.ts#L59-L62" }, { "kind": "enum", @@ -52386,7 +52409,7 @@ "name": "GeoValidationMethod", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/geo.ts#L163-L173" + "specLocation": "_types/query_dsl/geo.ts#L173-L183" }, { "attachedBehaviors": [ @@ -52488,7 +52511,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L61-L93" + "specLocation": "_types/query_dsl/geo.ts#L64-L96" }, { "kind": "type_alias", @@ -52523,6 +52546,90 @@ }, "specLocation": "_types/Geo.ts#L42-L51" }, + { + "inherits": { + "type": { + "name": "QueryBase", + "namespace": "_types.query_dsl" + } + }, + "kind": "interface", + "name": { + "name": "GeoGridQuery", + "namespace": "_types.query_dsl" + }, + "properties": [ + { + "name": "geogrid", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoTile", + "namespace": "_types" + } + } + }, + { + "name": "geohash", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoHash", + "namespace": "_types" + } + } + }, + { + "name": "geohex", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoHexCell", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/query_dsl/geo.ts#L98-L103", + "variants": { + "kind": "container" + } + }, + { + "description": "A map tile reference, represented as `{zoom}/{x}/{y}`", + "kind": "type_alias", + "name": { + "name": "GeoTile", + "namespace": "_types" + }, + "specLocation": "_types/Geo.ts#L93-L94", + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "description": "A map hex cell (H3) reference", + "kind": "type_alias", + "name": { + "name": "GeoHexCell", + "namespace": "_types" + }, + "specLocation": "_types/Geo.ts#L96-L97", + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, { "attachedBehaviors": [ "AdditionalProperty" @@ -52597,7 +52704,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L99-L111" + "specLocation": "_types/query_dsl/geo.ts#L109-L121" }, { "kind": "interface", @@ -52621,7 +52728,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L95-L97" + "specLocation": "_types/query_dsl/geo.ts#L105-L107" }, { "attachedBehaviors": [ @@ -52683,7 +52790,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L131-L147" + "specLocation": "_types/query_dsl/geo.ts#L141-L157" }, { "kind": "interface", @@ -52729,7 +52836,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L118-L129" + "specLocation": "_types/query_dsl/geo.ts#L128-L139" }, { "description": "A GeoJson shape, that can also use Elasticsearch's `envelope` extension.", @@ -52799,7 +52906,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L430-L447" + "specLocation": "_types/query_dsl/abstractions.ts#L436-L453" }, { "kind": "enum", @@ -53274,7 +53381,7 @@ } ], "shortcutProperty": "field", - "specLocation": "_types/query_dsl/abstractions.ts#L529-L543" + "specLocation": "_types/query_dsl/abstractions.ts#L535-L549" }, { "inherits": { @@ -60367,7 +60474,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L502-L511" + "specLocation": "_types/query_dsl/abstractions.ts#L508-L517" }, { "inherits": { @@ -78436,38 +78543,6 @@ } } }, - { - "description": "A map hex cell (H3) reference", - "kind": "type_alias", - "name": { - "name": "GeoHexCell", - "namespace": "_types" - }, - "specLocation": "_types/Geo.ts#L96-L97", - "type": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - } - }, - { - "description": "A map tile reference, represented as `{zoom}/{x}/{y}`", - "kind": "type_alias", - "name": { - "name": "GeoTile", - "namespace": "_types" - }, - "specLocation": "_types/Geo.ts#L93-L94", - "type": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - } - }, { "kind": "type_alias", "name": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 7c81d1150d..74f7debb82 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -81180,7 +81180,7 @@ "name": "CombinedFieldsOperator", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/abstractions.ts#L513-L516" + "specLocation": "_types/query_dsl/abstractions.ts#L519-L522" }, { "kind": "interface", @@ -81276,7 +81276,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L466-L500" + "specLocation": "_types/query_dsl/abstractions.ts#L472-L506" }, { "kind": "enum", @@ -81294,7 +81294,7 @@ "name": "CombinedFieldsZeroTerms", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/abstractions.ts#L518-L527" + "specLocation": "_types/query_dsl/abstractions.ts#L524-L533" }, { "kind": "interface", @@ -81958,7 +81958,7 @@ } ], "shortcutProperty": "field", - "specLocation": "_types/query_dsl/abstractions.ts#L529-L543" + "specLocation": "_types/query_dsl/abstractions.ts#L535-L549" }, { "kind": "interface", @@ -82016,7 +82016,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L430-L447" + "specLocation": "_types/query_dsl/abstractions.ts#L436-L453" }, { "kind": "enum", @@ -82607,7 +82607,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L32-L54" + "specLocation": "_types/query_dsl/geo.ts#L35-L57" }, { "kind": "interface", @@ -82774,7 +82774,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L61-L93" + "specLocation": "_types/query_dsl/geo.ts#L64-L96" }, { "kind": "enum", @@ -82790,7 +82790,59 @@ "name": "GeoExecution", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/geo.ts#L56-L59" + "specLocation": "_types/query_dsl/geo.ts#L59-L62" + }, + { + "kind": "interface", + "inherits": { + "type": { + "name": "QueryBase", + "namespace": "_types.query_dsl" + } + }, + "name": { + "name": "GeoGridQuery", + "namespace": "_types.query_dsl" + }, + "properties": [ + { + "name": "geogrid", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoTile", + "namespace": "_types" + } + } + }, + { + "name": "geohash", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoHash", + "namespace": "_types" + } + } + }, + { + "name": "geohex", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "GeoHexCell", + "namespace": "_types" + } + } + } + ], + "specLocation": "_types/query_dsl/geo.ts#L98-L103", + "variants": { + "kind": "container" + } }, { "kind": "interface", @@ -82814,7 +82866,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L95-L97" + "specLocation": "_types/query_dsl/geo.ts#L105-L107" }, { "kind": "interface", @@ -82890,7 +82942,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L99-L111" + "specLocation": "_types/query_dsl/geo.ts#L109-L121" }, { "kind": "interface", @@ -82936,7 +82988,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L118-L129" + "specLocation": "_types/query_dsl/geo.ts#L128-L139" }, { "kind": "interface", @@ -82998,7 +83050,7 @@ } } ], - "specLocation": "_types/query_dsl/geo.ts#L131-L147" + "specLocation": "_types/query_dsl/geo.ts#L141-L157" }, { "kind": "enum", @@ -83019,7 +83071,7 @@ "name": "GeoValidationMethod", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/geo.ts#L163-L173" + "specLocation": "_types/query_dsl/geo.ts#L173-L183" }, { "kind": "interface", @@ -85673,7 +85725,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L453-L464" + "specLocation": "_types/query_dsl/abstractions.ts#L459-L470" }, { "kind": "interface", @@ -85882,6 +85934,29 @@ } } }, + { + "description": "Matches `geo_point` and `geo_shape` values that intersect a grid cell from a GeoGrid aggregation.", + "name": "geo_grid", + "required": false, + "type": { + "kind": "dictionary_of", + "key": { + "kind": "instance_of", + "type": { + "name": "Field", + "namespace": "_types" + } + }, + "singleKey": true, + "value": { + "kind": "instance_of", + "type": { + "name": "GeoGridQuery", + "namespace": "_types.query_dsl" + } + } + } + }, { "deprecation": { "description": "Use geo-shape instead.", @@ -86738,7 +86813,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L102-L428", + "specLocation": "_types/query_dsl/abstractions.ts#L103-L434", "variants": { "kind": "container", "nonExhaustive": true @@ -89620,7 +89695,7 @@ } } ], - "specLocation": "_types/query_dsl/abstractions.ts#L502-L511" + "specLocation": "_types/query_dsl/abstractions.ts#L508-L517" }, { "kind": "enum", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 21c4e48d8e..64c8d9d5af 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -6090,6 +6090,12 @@ export type QueryDslGeoDistanceQuery = QueryDslGeoDistanceQueryKeys export type QueryDslGeoExecution = 'memory' | 'indexed' +export interface QueryDslGeoGridQuery extends QueryDslQueryBase { + geogrid?: GeoTile + geohash?: GeoHash + geohex?: GeoHexCell +} + export interface QueryDslGeoPolygonPoints { points: GeoLocation[] } @@ -6385,6 +6391,7 @@ export interface QueryDslQueryContainer { fuzzy?: Partial> geo_bounding_box?: QueryDslGeoBoundingBoxQuery geo_distance?: QueryDslGeoDistanceQuery + geo_grid?: Partial> geo_polygon?: QueryDslGeoPolygonQuery geo_shape?: QueryDslGeoShapeQuery has_child?: QueryDslHasChildQuery diff --git a/specification/_types/query_dsl/abstractions.ts b/specification/_types/query_dsl/abstractions.ts index 9c7c3767dc..1a560f79a2 100644 --- a/specification/_types/query_dsl/abstractions.ts +++ b/specification/_types/query_dsl/abstractions.ts @@ -48,6 +48,7 @@ import { import { GeoBoundingBoxQuery, GeoDistanceQuery, + GeoGridQuery, GeoPolygonQuery, GeoShapeQuery } from './geo' @@ -167,6 +168,11 @@ export class QueryContainer { * @ext_doc_id query-dsl-geo-distance-query */ geo_distance?: GeoDistanceQuery + + /** + * Matches `geo_point` and `geo_shape` values that intersect a grid cell from a GeoGrid aggregation. + */ + geo_grid?: SingleKeyDictionary /** * @deprecated 7.12.0 Use geo-shape instead. */ diff --git a/specification/_types/query_dsl/geo.ts b/specification/_types/query_dsl/geo.ts index e78d9d5fdf..d73e6327e3 100644 --- a/specification/_types/query_dsl/geo.ts +++ b/specification/_types/query_dsl/geo.ts @@ -23,9 +23,12 @@ import { Distance, GeoBounds, GeoDistanceType, + GeoHash, + GeoHexCell, GeoLocation, GeoShape, - GeoShapeRelation + GeoShapeRelation, + GeoTile } from '@_types/Geo' import { FieldLookup, QueryBase } from './abstractions' @@ -92,6 +95,13 @@ export class GeoDistanceQuery ignore_unmapped?: boolean } +/** @variants container */ +export class GeoGridQuery extends QueryBase { + geogrid?: GeoTile + geohash?: GeoHash + geohex?: GeoHexCell +} + export class GeoPolygonPoints { points: GeoLocation[] }