Skip to content

Commit

Permalink
Fix failing backport
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Jul 18, 2022
1 parent d5d95f6 commit b5a8918
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,24 @@ describe('readWithPit', () => {
expect(client.search).toHaveBeenCalledTimes(1);
expect(client.search).toHaveBeenCalledWith({
allow_partial_search_results: false,
pit: {
id: 'pitId',
keep_alive: '10m',
},
query: {
match_all: {},
},
search_after: undefined,
seq_no_primary_term: undefined,
size: 10000,
sort: '_shard_doc:asc',
track_total_hits: true,
body: {
pit: {
id: 'pitId',
keep_alive: '10m',
},
query: {
match_all: {},
},
search_after: undefined,
size: 10000,
sort: {
_shard_doc: {
order: 'asc',
},
},
track_total_hits: true,
},
});
});

Expand Down
29 changes: 17 additions & 12 deletions src/core/server/saved_objects/migrationsv2/actions/read_with_pit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ export const readWithPit =
.search<SavedObjectsRawDoc>({
allow_partial_search_results: false,
seq_no_primary_term: seqNoPrimaryTerm,
// Sort fields are required to use searchAfter
sort: '_shard_doc:asc',
pit: { id: pitId, keep_alive: pitKeepAlive },
size: batchSize,
search_after: searchAfter,
/**
* We want to know how many documents we need to process so we can log the progress.
* But we also want to increase the performance of these requests,
* so we ask ES to report the total count only on the first request (when searchAfter does not exist)
*/
track_total_hits: typeof searchAfter === 'undefined',
query,
body: {
// Sort fields are required to use searchAfter
sort: {
// the most efficient option as order is not important for the migration
_shard_doc: { order: 'asc' },
},
pit: { id: pitId, keep_alive: pitKeepAlive },
size: batchSize,
search_after: searchAfter,
/**
* We want to know how many documents we need to process so we can log the progress.
* But we also want to increase the performance of these requests,
* so we ask ES to report the total count only on the first request (when searchAfter does not exist)
*/
track_total_hits: typeof searchAfter === 'undefined',
query,
},
})
.then((response) => {
const totalHits =
Expand Down

0 comments on commit b5a8918

Please sign in to comment.