File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
src/search/scripts/index/utils Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,6 @@ export async function populateIndex(
40
40
options : Options ,
41
41
) {
42
42
console . log ( chalk . yellow ( `\nIndexing ${ chalk . bold ( indexName ) } ` ) )
43
- const bulkOperations = records . flatMap ( ( doc ) => [ { index : { _index : indexAlias } } , doc ] )
44
-
45
- const bulkOptions = {
46
- refresh : false ,
47
- timeout : '5m' ,
48
- }
49
43
50
44
const attempts = options . retries || 0
51
45
const sleepTime = options . sleepTime || DEFAULT_SLEEPTIME_SECONDS * 1000
@@ -57,7 +51,15 @@ export async function populateIndex(
57
51
const t0 = new Date ( )
58
52
const bulkResponse = await retryOnErrorTest (
59
53
( error ) => error instanceof errors . ResponseError && error . meta . statusCode === 429 ,
60
- ( ) => client . bulk ( { operations : bulkOperations , ...bulkOptions } ) ,
54
+ ( ) =>
55
+ client . helpers . bulk ( {
56
+ datasource : records ,
57
+ onDocument : ( ) => ( { index : { _index : indexAlias } } ) ,
58
+ flushBytes : 10_000_000 , // stop before breaker trips
59
+ concurrency : 2 , // back-off a bit
60
+ refreshOnCompletion : true ,
61
+ timeout : '5m' ,
62
+ } ) ,
61
63
{
62
64
attempts,
63
65
sleepTime,
You can’t perform that action at this time.
0 commit comments