Skip to content

Commit

Permalink
fix(search-indexer): Stop refreshing index immediately (#17069)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
RunarVestmann and kodiakhq[bot] authored Nov 28, 2024
1 parent 9ea0c3d commit 7d3961e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
14 changes: 2 additions & 12 deletions libs/content-search-indexer/src/lib/indexing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export class IndexingService {
let nextPageToken: string | undefined = undefined
let postSyncOptions: SyncResponse['postSyncOptions']

const isIncrementalUpdate = syncType === 'fromLast'

// Fetch initial page specifically in case importing is skipped (no need to wait for a new sync token if we don't need it)
{
const importerResponse = await importer.doSync({
Expand All @@ -83,11 +81,7 @@ export class IndexingService {
postSyncOptions: importerResponsePostSyncOptions,
...elasticData
} = importerResponse
await this.elasticService.bulk(
elasticIndex,
elasticData,
isIncrementalUpdate,
)
await this.elasticService.bulk(elasticIndex, elasticData)

nextPageToken = importerResponseNextPageToken
postSyncOptions = importerResponsePostSyncOptions
Expand Down Expand Up @@ -115,11 +109,7 @@ export class IndexingService {
postSyncOptions: importerResponsePostSyncOptions,
...elasticData
} = importerResponse
await this.elasticService.bulk(
elasticIndex,
elasticData,
isIncrementalUpdate,
)
await this.elasticService.bulk(elasticIndex, elasticData)

nextPageToken = importerResponseNextPageToken
postSyncOptions = importerResponsePostSyncOptions
Expand Down
11 changes: 3 additions & 8 deletions libs/content-search-toolkit/src/services/elastic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ElasticService {
}

// this can partially succeed
async bulk(index: string, documents: SyncRequest, refresh = false) {
async bulk(index: string, documents: SyncRequest) {
logger.info('Processing documents', {
index,
added: documents.add.length,
Expand Down Expand Up @@ -106,14 +106,10 @@ export class ElasticService {
return false
}

await this.bulkRequest(index, requests, refresh)
await this.bulkRequest(index, requests)
}

async bulkRequest(
index: string,
requests: Record<string, unknown>[],
refresh = false,
) {
async bulkRequest(index: string, requests: Record<string, unknown>[]) {
const chunkSize = 14
let delay = INITIAL_DELAY
let retries = MAX_RETRY_COUNT
Expand All @@ -129,7 +125,6 @@ export class ElasticService {
const response = await client.bulk({
index: index,
body: requestChunk,
refresh: refresh ? 'true' : undefined,
})

// not all errors are thrown log if the response has any errors
Expand Down

0 comments on commit 7d3961e

Please sign in to comment.