attributes, while judgments read its state and the images that their recipe names. Every write gives the document a new revision, and every answer names the revision that it read, so you can tell whether the answer is still current.
This document is a payment.
Fields
attributesis a flat map of at most 64 attributes, each a string, a number, a boolean, an array of strings ornull. Queries can filter and sort on attributes. Brussle sends an attribute to an engine only if a judgment’s context recipe names it.- All the documents of a namespace have at most 1,024 different attribute names, and Brussle refuses a write that adds one more name with
too_largeanddetails.limitattribute_names. In that error,details.idnames the document,details.pathits first new attribute (attributes.customer_8812, for example), anddetails.attribute_namesgives the current count. A name counts from the first write that uses it until you delete the namespace, so put values that vary (ids, dates and tags) in attribute values rather than in attribute names. Write{"customer": "8812"}, not{"customer_8812": true}. - A number reads back as you wrote it, and an integer keeps its exact value in the full signed and unsigned 64-bit range (
1790799482246605123comes back as1790799482246605123). Filters and ranking compare integers exactly. - A number with a fraction or an exponent, such as
2.5or3.0, is a 64-bit float, and it comes back as a float. A filter treats3and3.0as equal. nullmeans no value, so anupsertleaves that attribute out, apatchremoves it, a get does not return it, andExists falsematches it.
- All the documents of a namespace have at most 1,024 different attribute names, and Brussle refuses a write that adds one more name with
stateis the JSON content that judgments read, a JSON object of at most 1 MB that queries cannot filter on. Nothing instateis ever an image, whatever its shape.imagesmaps a name to one image or a list of images, at most 16 images in all. A write sends each image as a data URL, such as"data:image/png;base64,...". Brussle stores the image once, and the document holds a reference to it, such as{"digest": "sha256:...", "type": "image/png", "width": 1440, "height": 960}. A get always returnsimages({}when the document has none), and images do not count toward the 1 MB ofstate. A judgment reads an image only where its recipe names it, asimages.<name>, and only engines that read images see it. See images in documents.revisionis the version number of the document, and it goes up each time a write changes the document (anupsertalways does, even with the same content). Its value is the namespace’s sequence number at the change, so it always goes up but can skip numbers. Only your writes change it, so judging the document, a backfill, posting outcomes, a calibration fit or a new judgment leaves it as it was, and anif_revisionfrom your last read still matches.- A document that you wrote once has the same
revisionandincarnation. The documents of one request always share a revision, although documents written in different requests usually do not, so an import gives each of its batches a different revision even though it writes each document once. - Each answer names the
revisionthat it is for, and an answer that reads other documents also names itswatermark(each write at or below that position is in the answer). - The answer reads
pendingorstaleonce the document changes after it. See freshness.
- A document that you wrote once has the same
incarnationis the sequence number at which Brussle created the document. If you delete a document and write the sameidagain, the new document has a new incarnation and starts with no answers and no history, but the evaluations of earlier incarnations stay readable withall_incarnations=true.created_atis when the document was created, which is the time of the write that created it or thecreated_atthat write gave (at most 5 minutes in the future). Give a record’s original creation time when you import existing data. A later write never changescreated_at, but a new incarnation gets a newcreated_at. Relations read related documents newestcreated_atfirst.
Writing
POST /namespaces/{ns} writes documents, at most 1,000 documents or 64 MB in one request. A namespace holds at most 100,000,000 documents or 256 GB, and Brussle refuses a write past either limit with too_large. A write to a namespace that does not exist creates it, at most 1,000 new namespaces a minute for each organization. See namespace limits.
Brussle applies the operations of a request in this order: upsert, patch, append, delete. A request commits as one unit, never split across two commits.
You can always retry a write safely, since each write has the same result if Brussle applies it again. System behavior tells what a late retry does.
A write returns when its batch is durable (speed and limits).
Wait for answers
Addwait_for to a write to wait until the named judgments have answers for this revision.
wait_timeout_mssets the longest wait, 5,000 by default, and Brussle lowers a value above 10,000 to 10,000.- An empty
wait_foris the same as nowait_for. - The write is still committed if the wait times out, and the answers that were not ready come back
pending, which here means only that they were not ready in the wait time. - Brussle judges the first 16 documents of a large write at interactive priority and the rest in the usual order, so the answers for the rest usually come back
pending.
unavailable if the document was never judged in its current incarnation, and stale if its policy will not judge the new revision without a request from you.
Conditional upserts
Anupsert can have if_revision, and the write then commits only if the document’s current revision is exactly that value. 0 means “only if the document does not exist” (it was never written, or it was deleted).
Use if_revision to write back a document that you read, without overwriting a change that someone made after your read.
POST /v1/namespaces/acme%2Fprod
images back as you read them. Brussle stores nothing again, and bills only the references.
If the revision of any document differs, Brussle refuses the whole request with conflict and writes nothing in it. details.revisions gives the current revision of each document that did not match, or null if the document does not exist or has a write that is not committed yet.
conflict, read the document again and decide what to write.
- A retry of a conditional write can also get
conflictif the first attempt committed and the revision moved on, so read the document to find out. if_revisionis forupsertonly, so apatchor anappendalways applies.- A document from a request that is not committed yet has no revision to match, so a conditional write to it gets
conflict(withnullfor that document) until the other request commits.
Concurrent writes
Brussle applies the writes to one document in the order that they commit, so concurrentpatch and append writes from different clients all stand.
Brussle can refuse a write with rate_limited during a failover. Retry the write, as the SDKs do for you. See system behavior.
Reading
GET /namespaces/{ns}/documents/{id} returns the document with its answers.
- Add
include=historyto get its evaluations, newest first. - Add
include=history,context,rawto also get the compiled context and the raw engine response of each evaluation. - In the SDKs these are flags:
ns.get(id, include_history=True, include_context=True, include_raw=True)in Python, andns.get(id, { includeHistory: true, includeContext: true, includeRaw: true })in TypeScript.
GET /namespaces/{ns}/images/{digest} returns an image that a document names (images in documents).
POST /namespaces/{ns}/query filters, ranks and pages documents. See querying answers.