[maps][ESQL] fix esql layers do not support spatial filters drawn on map (#176753)

Closes https://github.com/elastic/kibana/issues/176752

### test instructions
1. install sample web logs 
2. create new map
3. add "ES|QL" layer
4. verify drawing tools are enable on map and drawing a filter narrows
ES|QL layer.
<img width="600" alt="Screenshot 2024-02-12 at 12 38 03 PM"
src="fffb77de-f2fd-43f0-9a87-a5f44ff68ee2">
This commit is contained in:
Nathan Reese 2024-02-12 14:22:01 -07:00 committed by GitHub
parent 8af71e4889
commit 7f4208ac9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 4 deletions

View file

@ -51,7 +51,9 @@ export type ESQLSourceDescriptor = AbstractSourceDescriptor & {
*/
dateField?: string;
/*
* Geo field used to narrow ES|QL requests by visible map area
* Geo field used to narrow ES|QL requests by
* 1. by visible map area
* 2. spatial filters drawn on map
*/
geoField?: string;
narrowByGlobalSearch: boolean;

View file

@ -577,7 +577,10 @@ export class AbstractLayer implements ILayer {
getGeoFieldNames(): string[] {
const source = this.getSource();
return hasESSourceMethod(source, 'getGeoFieldName') ? [source.getGeoFieldName()] : [];
const geoFieldName = hasESSourceMethod(source, 'getGeoFieldName')
? source.getGeoFieldName()
: undefined;
return geoFieldName ? [geoFieldName] : [];
}
async getStyleMetaDescriptorFromLocalFeatures(): Promise<StyleMetaDescriptor | null> {

View file

@ -49,7 +49,7 @@ export interface IESSource extends IVectorSource {
getIndexPatternId(): string;
getGeoFieldName(): string;
getGeoFieldName(): string | undefined;
loadStylePropsMeta({
layerName,

View file

@ -28,6 +28,7 @@ import { isValidStringConfig } from '../../util/valid_string_config';
import type { SourceEditorArgs } from '../source';
import { AbstractVectorSource, getLayerFeaturesRequestName } from '../vector_source';
import type { IVectorSource, GeoJsonWithMeta, SourceStatus } from '../vector_source';
import type { IESSource } from '../es_source';
import type { IField } from '../../fields/field';
import { InlineField } from '../../fields/inline_field';
import { getData, getUiSettings } from '../../../kibana_services';
@ -44,7 +45,10 @@ export const sourceTitle = i18n.translate('xpack.maps.source.esqlSearchTitle', {
defaultMessage: 'ES|QL',
});
export class ESQLSource extends AbstractVectorSource implements IVectorSource {
export class ESQLSource
extends AbstractVectorSource
implements IVectorSource, Pick<IESSource, 'getIndexPatternId' | 'getGeoFieldName'>
{
readonly _descriptor: ESQLSourceDescriptor;
static createDescriptor(descriptor: Partial<ESQLSourceDescriptor>): ESQLSourceDescriptor {
@ -325,4 +329,8 @@ export class ESQLSource extends AbstractVectorSource implements IVectorSource {
getIndexPatternId() {
return this._descriptor.dataViewId;
}
getGeoFieldName() {
return this._descriptor.geoField;
}
}