Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
26c47bd
[Search] Add request context and asScoped pattern
lukasolson Oct 15, 2020
36b8fcb
Update docs
lukasolson Oct 15, 2020
8274226
Merge branch 'master' into search-as-scoped
lukasolson Oct 16, 2020
c7296f0
Unify interface for getting search client
lukasolson Oct 19, 2020
9dadfb2
Update examples/search_examples/server/my_strategy.ts
lukasolson Oct 20, 2020
ab55bcb
Merge branch 'master' into search-as-scoped
lukasolson Oct 26, 2020
2b3d2a0
Review feedback
lukasolson Oct 26, 2020
7a048a0
Merge branch 'search-as-scoped' of github.com:lukasolson/kibana into …
lukasolson Oct 26, 2020
2d0da67
Merge branch 'master' into search-as-scoped
lukasolson Oct 27, 2020
f7cb5a1
Merge branch 'master' into search-as-scoped
lukasolson Oct 28, 2020
6c9aec5
Fix checks
lukasolson Oct 28, 2020
1ae55ef
Fix CI
lukasolson Oct 29, 2020
4634fb4
Fix security search
lukasolson Oct 29, 2020
c35fb49
Merge branch 'master' into search-as-scoped
lukasolson Oct 30, 2020
1567995
Merge branch 'master' into search-as-scoped
lukasolson Nov 2, 2020
5f7c9ab
Fix test
lukasolson Nov 2, 2020
f1b515d
Fix test for reals
lukasolson Nov 2, 2020
b0860e7
Merge branch 'master' into search-as-scoped
lukasolson Nov 3, 2020
11517ee
Fix types
lukasolson Nov 3, 2020
b1e06b0
[data.search] Refactor search polling and improve types
lukasolson Nov 3, 2020
8e8eae8
Merge branch 'master' into search-poll
lukasolson Nov 4, 2020
5f41a97
Merge branch 'master' of github.com:elastic/kibana into pr/82545
Nov 10, 2020
8e72dce
Merge branch 'master' into search-poll
lukasolson Nov 19, 2020
cf2b31d
Fix & update tests & types
lukasolson Nov 20, 2020
10a2f92
Merge branch 'master' into search-poll
kibanamachine Nov 21, 2020
01e8a06
eql totals
Nov 22, 2020
7874b18
doc
Nov 22, 2020
07d6b72
Revert "eql totals"
Nov 22, 2020
9ee668b
Merge branch 'master' of github.com:elastic/kibana into pr/82545
Nov 22, 2020
b61ebc3
lint
Nov 22, 2020
98c2c47
response type
Nov 22, 2020
09eaaac
Merge branch 'master' of github.com:elastic/kibana into pr/82545
Nov 24, 2020
2ba358f
shim inside strategies
Nov 24, 2020
1ad2f0b
shim for security
Nov 24, 2020
d4ef755
Merge branch 'master' of github.com:elastic/kibana into pr/82545
Nov 24, 2020
168214b
fix eql params
Nov 24, 2020
1c14a36
Merge branch 'master' of github.com:elastic/kibana into pr/82545
Nov 24, 2020
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
55 changes: 0 additions & 55 deletions src/plugins/data/common/search/es_search/es_search_rxjs_utils.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/plugins/data/common/search/es_search/get_total_loaded.test.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/plugins/data/common/search/es_search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@
*/

export * from './types';
export * from './utils';
export * from './es_search_rxjs_utils';
export * from './shim_abort_signal';
export * from './to_snake_case';
export * from './get_total_loaded';
64 changes: 0 additions & 64 deletions src/plugins/data/common/search/es_search/shim_abort_signal.test.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/plugins/data/common/search/es_search/shim_abort_signal.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/plugins/data/common/search/es_search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,4 @@ export interface IEsSearchRequest extends IKibanaSearchRequest<ISearchRequestPar
indexType?: string;
}

export interface IEsRawSearchResponse<Source = any> extends SearchResponse<Source> {
id?: string;
is_partial?: boolean;
is_running?: boolean;
}

export type IEsSearchResponse<Source = any> = IKibanaSearchResponse<SearchResponse<Source>>;
1 change: 1 addition & 0 deletions src/plugins/data/common/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export * from './search_source';
export * from './tabify';
export * from './types';
export * from './session';
export * from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
* under the License.
*/

import { mapKeys, snakeCase } from 'lodash';
import { isErrorResponse, isCompleteResponse, isPartialResponse } from './utils';

export function toSnakeCase(obj: Record<string, any>): Record<string, any> {
return mapKeys(obj, (value, key) => snakeCase(key));
}
describe('utils', () => {
describe('isErrorResponse', () => {});

describe('isCompleteResponse', () => {});

describe('isPartialResponse', () => {});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import type { IKibanaSearchResponse } from '../types';
import type { IKibanaSearchResponse } from './types';

/**
* @returns true if response had an error while executing in ES
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/public/search/errors/painless_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import { ApplicationStart } from 'kibana/public';
import { IEsError, isEsError } from './types';
import { EsError } from './es_error';
import { getRootCause } from './utils';
import { IKibanaSearchRequest } from '..';

export class PainlessError extends EsError {
painlessStack?: string;
constructor(err: IEsError, request: IKibanaSearchRequest) {
constructor(err: IEsError) {
super(err);
}

Expand Down
16 changes: 5 additions & 11 deletions src/plugins/data/public/search/search_interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ export class SearchInterceptor {
* @returns `Error` a search service specific error or the original error, if a specific error can't be recognized.
* @internal
*/
protected handleSearchError(
e: any,
request: IKibanaSearchRequest,
timeoutSignal: AbortSignal,
options?: ISearchOptions
): Error {
protected handleSearchError(e: any, timeoutSignal: AbortSignal, options?: ISearchOptions): Error {
if (timeoutSignal.aborted || get(e, 'body.message') === 'Request timed out') {
// Handle a client or a server side timeout
const err = new SearchTimeoutError(e, this.getTimeoutMode());
Expand All @@ -113,7 +108,7 @@ export class SearchInterceptor {
return e;
} else if (isEsError(e)) {
if (isPainlessError(e)) {
return new PainlessError(e, request);
return new PainlessError(e);
} else {
return new EsError(e);
}
Expand All @@ -126,13 +121,12 @@ export class SearchInterceptor {
* @internal
*/
protected runSearch(
request: IKibanaSearchRequest,
{ id, ...request }: IKibanaSearchRequest,
signal: AbortSignal,
strategy?: string
): Promise<IKibanaSearchResponse> {
const { id, ...searchRequest } = request;
const path = trimEnd(`/internal/search/${strategy || ES_SEARCH_STRATEGY}/${id || ''}`, '/');
const body = JSON.stringify(searchRequest);
const body = JSON.stringify(request);

return this.deps.http.fetch({
method: 'POST',
Expand Down Expand Up @@ -236,7 +230,7 @@ export class SearchInterceptor {
this.pendingCount$.next(this.pendingCount$.getValue() + 1);
return from(this.runSearch(request, combinedSignal, options?.strategy)).pipe(
catchError((e: Error) => {
return throwError(this.handleSearchError(e, request, timeoutSignal, options));
return throwError(this.handleSearchError(e, timeoutSignal, options));
}),
finalize(() => {
this.pendingCount$.next(this.pendingCount$.getValue() - 1);
Expand Down
16 changes: 4 additions & 12 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,19 @@ export {
SearchStrategyDependencies,
getDefaultSearchParams,
getShardTimeout,
getTotalLoaded,
toKibanaSearchResponse,
shimHitsTotal,
usageProvider,
searchUsageObserver,
shimAbortSignal,
SearchUsage,
} from './search';

import { trackSearchStatus } from './search';

// Search namespace
export const search = {
esSearch: {
utils: {
doSearch,
shimAbortSignal,
trackSearchStatus,
includeTotalLoaded,
toKibanaSearchResponse,
// utils:
getTotalLoaded,
toSnakeCase,
},
},
aggs: {
CidrMask,
dateHistogramInterval,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/server/search/collectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* under the License.
*/

export { usageProvider, SearchUsage } from './usage';
export type { SearchUsage } from './usage';
export { usageProvider, searchUsageObserver } from './usage';
21 changes: 19 additions & 2 deletions src/plugins/data/server/search/collectors/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* under the License.
*/

import { CoreSetup } from 'kibana/server';
import { Usage } from './register';
import type { CoreSetup, Logger } from 'kibana/server';
import type { IEsSearchResponse } from '../../../common';
import type { Usage } from './register';

const SAVED_OBJECT_ID = 'search-telemetry';

Expand Down Expand Up @@ -74,3 +75,19 @@ export function usageProvider(core: CoreSetup): SearchUsage {
trackSuccess: getTracker('successCount'),
};
}

/**
* Rxjs observer for easily doing `tap(searchUsageObserver(logger, usage))` in an rxjs chain.
*/
export function searchUsageObserver(logger: Logger, usage?: SearchUsage) {
return {
next(response: IEsSearchResponse) {
logger.debug(`trackSearchStatus:next ${response.rawResponse.took}`);
usage?.trackSuccess(response.rawResponse.took);
},
error() {
logger.debug(`trackSearchStatus:error`);
usage?.trackError();
},
};
}
Loading