Skip to content
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

[Maps] [Infra] do not import types from the legacy elasticsearch package #107118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { GenericParams, SearchResponse } from 'elasticsearch';
import type { estypes } from '@elastic/elasticsearch';
import { Lifecycle } from '@hapi/hapi';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { JsonArray, JsonValue } from '@kbn/common-utils';
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface InfraServerPluginStartDeps {
data: DataPluginStart;
}

export interface CallWithRequestParams extends GenericParams {
export interface CallWithRequestParams extends estypes.RequestBase {
max_concurrent_shard_requests?: number;
name?: string;
index?: string | string[];
Expand All @@ -50,6 +50,7 @@ export interface CallWithRequestParams extends GenericParams {
path?: string;
query?: string | object;
track_total_hits?: boolean | number;
body?: any;
}

export type InfraResponse = Lifecycle.ReturnValue;
Expand Down Expand Up @@ -117,7 +118,7 @@ export interface InfraDatabaseGetIndicesResponse {
};
}

export type SearchHit = SearchResponse<object>['hits']['hits'][0];
export type SearchHit = estypes.SearchHit;

export interface SortedSearchHit extends SearchHit {
sort: any[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, { ReactElement } from 'react';
import { i18n } from '@kbn/i18n';
import rison from 'rison-node';
import { Feature } from 'geojson';
import { SearchResponse } from 'elasticsearch';
import type { estypes } from '@elastic/elasticsearch';
import {
convertCompositeRespToGeoJson,
convertRegularRespToGeoJson,
Expand Down Expand Up @@ -274,7 +274,7 @@ export class ESGeoGridSource extends AbstractESAggSource implements ITiledSingle
const requestId: string = afterKey
? `${this.getId()} afterKey ${afterKey.geoSplit}`
: this.getId();
const esResponse: SearchResponse<unknown> = await this._runEsQuery({
const esResponse: estypes.SearchResponse<unknown> = await this._runEsQuery({
requestId,
requestName: `${layerName} (${requestCount})`,
searchSource,
Expand All @@ -291,8 +291,10 @@ export class ESGeoGridSource extends AbstractESAggSource implements ITiledSingle

features.push(...convertCompositeRespToGeoJson(esResponse, this._descriptor.requestType));

afterKey = esResponse.aggregations.compositeSplit.after_key;
if (esResponse.aggregations.compositeSplit.buckets.length < gridsPerRequest) {
const aggr = esResponse.aggregations
?.compositeSplit as estypes.AggregationsCompositeBucketAggregate;
afterKey = aggr.after_key;
if (aggr.buckets.length < gridsPerRequest) {
// Finished because request did not get full resultset back
break;
}
Expand Down