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(
4040 options : Options ,
4141) {
4242 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- }
4943
5044 const attempts = options . retries || 0
5145 const sleepTime = options . sleepTime || DEFAULT_SLEEPTIME_SECONDS * 1000
@@ -57,7 +51,15 @@ export async function populateIndex(
5751 const t0 = new Date ( )
5852 const bulkResponse = await retryOnErrorTest (
5953 ( 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+ } ) ,
6163 {
6264 attempts,
6365 sleepTime,
You can’t perform that action at this time.
0 commit comments