document – Contains the data to be uploaded in the structure specified in the data schema configuration file.
collection_name – Specifies the name of the Collection into which to load the document.
Uploading a Batch of Documents
Data can be uploaded in batches by conversion of the documents to a document object before uploading. The basic data point object for the Hyperspace database is a structure of python dictionaries.
To upload a batch of documents into a Collection –
We recommend that you upload data to a Collection in batches of many documents each, which has the structure specified in the data schema configuration file.
The following code snippet builds a list of documents in a temporary variable named batch and then uploads each batch using –
The following example builds batches of 250 random documents for Hybrid Search. Each time it creates a random document, it loads it into a batch and then uploads the batch. Once a batch reaches 250 documents, it's uploaded to the Hyperspace Collection. Replace the yellow highlighted line below with code that retrieves the next document to be uploaded.
In the above example, Hyperspace will assign the each document with a random id. If you want to manually assign id , each document must include an id type field, as explained in Database schema config file. The id must be of type keyword/string.
At the moment, it is not possible to upload additional documents after commit. This will be changed in next versions.