Skip to content

Commit

Permalink
[Maps] [Infra] do not import types from the legacy elasticsearch pack…
Browse files Browse the repository at this point in the history
…age (elastic#107118)

* remove elasticsearch import from infra

* remove elasticsearch import from maps
  • Loading branch information
mshustov authored and vadimkibana committed Aug 8, 2021
1 parent 0b6e47b commit 0db58e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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

0 comments on commit 0db58e4

Please sign in to comment.