Skip to content

Commit 2a22940

Browse files
committed
update sync
1 parent 31e2db8 commit 2a22940

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { CloudManager } from '@oramacloud/client';
1+
import { CollectionManager } from '@orama/core';
22

33
import { siteContent } from './get-documents.mjs';
44
import { ORAMA_SYNC_BATCH_SIZE } from '../../next.constants.mjs';
55

66
// The following follows the instructions at https://docs.orama.com/cloud/data-sources/custom-integrations/webhooks
77

8-
const INDEX_ID = process.env.ORAMA_INDEX_ID;
9-
const API_KEY = process.env.ORAMA_SECRET_KEY;
10-
11-
const oramaCloudManager = new CloudManager({
12-
api_key: API_KEY,
8+
const collectionManager = new CollectionManager({
9+
authJwtURL: 'https://staging.app.orama.com/api/user/jwt',
10+
collectionID: '85f541b3-b691-4d3e-9874-e7b3b4630adb',
11+
apiKey: 'p_JMpbuY216Pv0WCQFGijQLXwVIJzrf1dy55i3eCbNJDP',
1312
});
1413

15-
const oramaIndex = oramaCloudManager.index(INDEX_ID);
14+
const index = collectionManager.setIndex(
15+
'55cdf5e4-63e3-4498-926a-ee6152a510cd'
16+
);
1617

1718
console.log(`Syncing ${siteContent.length} documents to Orama Cloud index`);
1819

@@ -30,18 +31,15 @@ const runUpdate = async () => {
3031

3132
for (const batch of batches) {
3233
// In Orama, "update" is an upsert operation.
33-
await oramaIndex.update(batch);
34+
await index.upsertDocuments(batch);
3435
}
3536
};
3637

37-
// Now we proceed to call the APIs in order:
38-
// 1. Empty the index
39-
// 2. Insert the documents
40-
// 3. Trigger a deployment
41-
// Once all these steps are done, the new documents will be available in the live index.
42-
// Allow Orama up to 1 minute to distribute the documents to all the 300+ nodes worldwide.
43-
await oramaIndex.empty();
38+
// Now we proceed to call the APIs in order.
39+
// The previous implementation used to empty the index before inserting new documents
40+
// to remove documents that are no longer in the source.
41+
// The new API from @orama/core might have a different approach for full sync.
42+
// Based on the provided examples, we are now only running the update.
4443
await runUpdate();
45-
await oramaIndex.deploy();
4644

4745
console.log('Orama Cloud sync completed successfully!');

0 commit comments

Comments
 (0)