-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Fix duplication in the search results #8409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,17 @@ import { OramaCloud } from '@orama/core'; | |
| import { getDocuments } from './get-documents.mjs'; | ||
| import { ORAMA_SYNC_BATCH_SIZE } from '../../next.constants.mjs'; | ||
|
|
||
| // The following follows the instructions at https://docs.orama.com/cloud/data-sources/custom-integrations/webhooks | ||
| // The following follows the instructions at https://docs.oramasearch.com/docs/cloud/data-sources/rest-APIs/using-rest-apis | ||
|
|
||
| const orama = new OramaCloud({ | ||
| projectId: process.env.NEW_ORAMA_PROJECT_ID || '', | ||
| apiKey: process.env.NEW_ORAMA_PRIVATE_API_KEY || '', | ||
| }); | ||
|
|
||
| const datasource = orama.dataSource(process.env.NEW_ORAMA_DATASOURCE_ID || ''); | ||
|
|
||
| // Create a temporary index to perform the insertions | ||
| const temporary = await datasource.createTemporaryIndex(); | ||
|
||
| const documents = await getDocuments(); | ||
|
|
||
| console.log(`Syncing ${documents.length} documents to Orama Cloud index`); | ||
|
|
@@ -27,16 +30,15 @@ const runUpdate = async () => { | |
|
|
||
| console.log(`Sending ${batches.length} batches of ${batchSize} documents`); | ||
|
|
||
| // Insert documents batch by batch into the temporary index | ||
| for (const batch of batches) { | ||
| await datasource.insertDocuments(batch); | ||
| await temporary.insertDocuments(batch); | ||
| } | ||
|
|
||
| // Once all documents are inserted into the temporary index, we swap it with the live one atomically. | ||
| await temporary.swap(); | ||
| }; | ||
|
|
||
| // Now we proceed to call the APIs in order. | ||
| // The previous implementation used to empty the index before inserting new documents | ||
| // to remove documents that are no longer in the source. | ||
| // The new API from @orama/core might have a different approach for full sync. | ||
| // Based on the provided examples, we are now only running the update. | ||
| await runUpdate(); | ||
|
|
||
| console.log('Orama Cloud sync completed successfully!'); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.