Skip to content

Commit

Permalink
[Search Sessions] fix saved object can be created even if courier:bat…
Browse files Browse the repository at this point in the history
…chSearches is enabled (#105407) (#105733)

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
  • Loading branch information
kibanamachine and Dosant authored Jul 15, 2021
1 parent 000aca3 commit 0e44fc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/data/common/search/search_source/search_source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,16 @@ describe('SearchSource', () => {
expect(callOptions.strategy).toBe(ES_SEARCH_STRATEGY);
});

test('should remove searchSessionId when forcing ES_SEARCH_STRATEGY', async () => {
searchSource = new SearchSource({ index: indexPattern }, searchSourceDependencies);
const options = { sessionId: 'test' };
await searchSource.fetch$(options).toPromise();

const [, callOptions] = mockSearchMethod.mock.calls[0];
expect(callOptions.strategy).toBe(ES_SEARCH_STRATEGY);
expect(callOptions.sessionId).toBeUndefined();
});

test('should not override strategy if set ', async () => {
searchSource = new SearchSource({ index: indexPattern }, searchSourceDependencies);
const options = { strategy: 'banana' };
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/common/search/search_source/search_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ export class SearchSource {
// This still uses bfetch for batching.
if (!options?.strategy && syncSearchByDefault) {
options.strategy = ES_SEARCH_STRATEGY;
// `ES_SEARCH_STRATEGY` doesn't support search sessions, hence remove sessionId
options.sessionId = undefined;
}

const s$ = defer(() => this.requestIsStarting(options)).pipe(
Expand Down

0 comments on commit 0e44fc8

Please sign in to comment.