Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"@opentelemetry/api-logs": "~0.206.0",
"@opentelemetry/instrumentation": "~0.206.0",
"@opentelemetry/resources": "~1.30.1",
"@orama/core": "^1.2.13",
"@orama/ui": "^1.5.3",
"@opentelemetry/sdk-logs": "~0.206.0",
"@orama/core": "^1.2.14",
"@orama/ui": "^1.5.3",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-tooltip": "^1.2.8",
"@tailwindcss/postcss": "~4.1.17",
Expand Down
16 changes: 9 additions & 7 deletions apps/site/scripts/orama-search/sync-orama-cloud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temporary index is created at the top level before documents are fetched. If createTemporaryIndex() fails or if the script crashes after creating the temporary index but before swapping, the temporary index may remain orphaned. Consider creating the temporary index inside runUpdate() after successfully fetching documents, or add cleanup logic to handle failures.

Copilot uses AI. Check for mistakes.
const documents = await getDocuments();

console.log(`Syncing ${documents.length} documents to Orama Cloud index`);
Expand All @@ -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!');
85 changes: 49 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading