Skip to main content
Once you know which attributes already link one of your records to another, you know what a judgment can read beside the document it judges. A support ticket whose attributes.account_id holds the id of a CRM account points at that account, so a judgment on the ticket can read the account. Brussle samples your documents and lists each attribute whose values are the ids of other documents. It creates nothing, so you use a suggestion by declaring it as a relation in a judgment’s context recipe. An answer that reads only its own document needs no relation. A relation reads only documents in the judged document’s own namespace, so write your support tickets and your CRM accounts into the same one. A namespace is usually one tenant or one environment, which means you use acme/prod/tenant_123 for both rather than acme/prod/tenant_123/crm and acme/prod/tenant_123/support. Decide where each record goes before your first write, since moving documents to another namespace later means writing them again. A ticket in the same namespace as its account points to it, and a judgment can read both documents. Split them across two namespaces and a relation on the same account_id reads nothing. The rule covers only the records a judgment reads together, so data that no judgment reads with other data can have a namespace of its own.

Ask for suggestions

Once you have written some documents, ask for suggestions.
Brussle reads a sample of up to 1,000 documents from the namespace and returns a response like this one.

Check the kinds

Brussle sorts the sampled documents into kinds (tickets, invoices and accounts, for example), taking the value of one attribute that has few different values as each document’s kind.
  • kind.attribute names this attribute, which is type in the example.
  • kind.values gives each value, with the number of sampled documents that have it.
  • kind.candidates lists the other attributes that could be the kind attribute, since a status or a plan also has few values and Brussle can choose the wrong attribute.
If Brussle chose the wrong attribute, send a different one with ns.suggest_relations(kind="object") or ns.suggestRelations({ kind: "object" }). Brussle refuses an attribute that cannot be a kind attribute with invalid_request. Brussle treats the whole sample as one kind when no attribute can be the kind attribute, and kind.attribute is then null. Each entry in relations is one attribute whose values name other documents. Brussle examines up to 100 sampled documents of each kind. In each entry, from names the kind and documents is the number of those documents that have the attribute. A value resolves when it is the id of a different document that exists in the namespace. Each entry has these counts:
  • resolved of sampled_values is how many values of the attribute resolve. Brussle counts values rather than documents, so an attribute that most documents do not have can still resolve 97 of 100.
  • to is the kind of most of the documents that the values name, and resolved_by_kind gives the count for each kind.
  • unresolved is the number of values that name no document, and unresolved_examples shows up to 5 of them. A value can name a deleted document, a document that you have not written yet, or a placeholder such as "n/a".
  • self_references is the number of values that name the document holding them. An account whose account_id is its own id points to itself rather than to a different document, so Brussle counts that value here and never in resolved.
  • array_lengths is for an attribute that holds a list of ids, where each item in a list counts as one value. It shows the min, max and mean length of the lists.
The sampled tickets in the example have 100 account_id values, of which 97 name an account and 3 name no document. A value that resolves is evidence of a possible relation, not proof of one, since a short string such as "open" can be the id of a document by chance. Check what the attribute means before you declare it. The counts describe the sample rather than the namespace, so 97 of 100 sampled values says the attribute looks reliable and makes no claim that 97% of all its values resolve.

What a request reads and costs

Each request has one budget with four limits, and budget shows each limit with how much of it the request used:
  • documents_read counts the documents in the sample.
  • attributes_examined counts the attributes that Brussle examined.
  • ids_looked_up counts the values that Brussle looked up as document ids.
  • bytes_read counts the bytes that Brussle read.
Brussle stops when attributes_examined, ids_looked_up or bytes_read runs out, and returns what it found so far with complete: false and exhausted naming the limit. Large attribute values, many kinds and long lists of ids use up the budget. documents_read sets only the size of the sample, so exhausted never names it. Brussle bills the request like a query, by the bytes it reads (the names and values of the sampled documents’ attributes, without their state). Since usage.bytes_scanned equals budget.bytes_read.used, the budget also limits what one request costs. Brussle takes the same sample from a namespace that has not changed, so asking again with no write in between returns the same response.

Ask on a template

A request on a template prefix such as acme/prod/* samples one tenant’s documents as an example of what the template’s tenants hold, and names that namespace in tenant. To see another tenant’s suggestions, ask on its namespace.

See them in the dashboard

A namespace that has documents but no judgments opens its Judgments tab on the suggestions, so you see your links before you declare any.

Declare what you found

Suggestions find attributes that hold the id of another document (or a list of them), and each one can connect documents in two ways:
  • The documents that point at the judged one, such as the payments that point at an order. See related documents.
  • The document the judged one points at, or the list it names, such as the product of an order line. See the referenced document.
Suggestions do not find the other kinds of relation, because no attribute holds an id for them: candidates that share a key you choose, the document as the judgment last saw it, and the other kinds that read another judgment’s answers or outcomes. Once a relation reads the records it needs, counts from them can be features that the fit on your outcomes weighs.