Across your customers
Questions about all the customers under one parent space: exact counts and lists, one ranked search across customers, and themes with customer counts.
For a company whose customers each have their own memory space under one parent (org:acme/user:c42,
org:acme/user:c43, ...), three lanes answer questions about all of them. They are experimental and
off by default; your admin turns each part on.
| Lane | What you get | Model call |
|---|---|---|
| Exact counts and lists | Exact answers to counts, lists, "top" and funnel questions over the labels and kinds on every customer's memories. Not a sample. | None |
| Search across customers | One ranked search across every customer space the caller may read, with a few memories from each customer. | None (the search model only) |
| Themes across customers | For "what do customers say about X?": themes, the number of customers behind each, checked examples, and how much was read. | Yes, and it can take up to a minute |
Example questions: "Which customers cancelled an order last week?" returns an exact list, or "0 of 240". "Which customers asked about financing in chat?" is a search across customers. "What do customers ask about EMI?" returns themes with customer counts and "read 212 of 212".
Turn it on
| Setting | What it turns on |
|---|---|
CORTEX_COHORT=on | The exact lane (POST /v1/cohort/query, GET /v1/cohort/vocabulary) and the cohort field on /v1/answer. Off, they answer 409 COHORT_DISABLED. |
CORTEX_SUBTREE_RECALL=request | The ranked search (subtree on /v1/recall) and the themes lane. Counts and lists keep working without it. |
Every lane needs scope.read.descend on the parent scope, and answers only over the customers the caller
may read, deciding each customer's space on its own. It reports nothing about the ones left out.
Ask for an exact count or list
POST /v1/cohort/query takes exactly one of a plan or a question, and calls no model:
{
"scope": "org:acme",
"plan": {"op": "top", "where": {"labels_all": ["etype:view"]}, "group_by": "label:model",
"metric": "subjects", "n": 5}
}GET /v1/cohort/vocabulary?scope=org:acme lists the labels and kinds a plan can use. The answer is
exact over the labels and kinds your app saved, so label memories consistently (for example
etype:order_cancelled) for these questions to work.
Search across customers
Add subtree to a recall at the parent scope with the walking view descend:
{
"scope": "org:acme",
"view": "descend",
"query": "financing and EMI questions",
"subtree": {"per_subject": 2, "max_subjects": 40}
}Without subtree, a recall at a parent scope reads the spaces under it in storage order, not by
relevance, and the pack says so.
Themes across customers
Ask /v1/answer at the parent scope with a cohort field. The same field also routes counts and
lists asked in plain words to the exact lane:
{
"scope": "org:acme",
"question": "What do customers ask about EMI?",
"cohort": {"naming": "alias", "anchor": "data_end", "max_listed": 50}
}For a themes question, CortexDB reads every matching conversation, counts the customers behind each
theme, checks examples before citing them, and says how much it read. It calls your answer model on each
question, within CORTEX_COHORT_ANSWER_BUDGET_MS.
Check support first
These lanes are experimental. Probe a server before you rely on them: a server without them answers an
unknown cohort field on /v1/answer from its ordinary parent-scope pack, so treat an answer without a
cohort field as "no cohort lanes here", never as a cohort answer.
See also
- POST /v1/recall: views,
extra_scopesand thedescendview. - Multi-Tenancy: one space per customer under a parent.