Overview

A document is a JSON object containing:

  • A content field, which contains the text string you provided to Memora. This is the main content that Memora uses to rank the relevance of documents in response to search queries.
  • An id field created by Memora to uniquely identify the document. It is an ULID.
  • Any additional fields (metadata) that you sent along with your document to Memora.

A sample document

Below is an example document without any metadata:

{
  "id": "01H3YY4RTACHHNMSM71JNREP56",
  "content": "The Answer to the Ultimate Question of Life, the Universe, and Everything is 42"
}

Working with documents

Working with documents in Memora is straightforward. You can create, delete, and update them according to your needs.

Inserting documents

To add a single document to Memora, you use the memora.add() function and pass in your string as the argument. This function returns the ULID of the newly inserted document, which you can use for future reference or operations.

id is the ULID that Memora creates for the newly inserted document. You can use it later to delete and update the document.

If you need to insert multiple documents at once, simply pass an array of strings to memora.add(). This returns an array of ULIDs corresponding to the inserted documents.

Even in batch mode, each insertion counts as a single request. For Hobby plan users, there’s a rate limit of 30 requests per minute. Therefore, you cannot perform more than 30 insertions at a time if you’re on the Hobby plan.

To learn more about limits, click here.

Deleting a document

To delete a document, use memora.delete().document(id) and pass the ULID of the document you want to remove.

Updating a document

As of now, Memora does not support updating existing documents. We apologize for any inconvenience.

Metadata

Documents can also include metadata. Metadata is extra information that you send to Memora, which is not used in our multistage reranking process. However, it does provide additional functionality:

  • Presence in Retrieval: Whenever a document is retrieved — either through a search or manually — the associated metadata is included.
  • Metadata Filtering: If your documents contain metadata, you can filter your searches based on this information. This feature allows you to narrow down your search results even further.

Inserting document with metadata

Adding metadata to a document in Memora is simple. You pass a second argument to memora.add() which should be an object containing your metadata. This function then returns the ULID of the inserted document.

Example document with metadata

Here’s a document with metadata in it:

{
  "id": "01H3YY4RTACHHNMSM71JNREP56",
  "content": "The Answer to the Ultimate Question of Life, the Universe, and Everything is 42",
  
  // metadata
  "book": "The Hitchhiker's Guide to the Galaxy",
  "author": "Douglas Adams",
  "published_at": 1978
}

Batch inserting

If you need to insert multiple documents with metadata, you can pass two arrays to memora.add(). The first array should contain your document contents, and the second one should contain the corresponding metadata objects. The function then returns an array of ULIDs corresponding to the inserted documents.

Limits

To learn more about limits related to documents, refer to this page.