Release binaries only, not in the public build.
/_facts,--facts-model-dirand thexerj_facts_askMCP tool are in the published release binaries (rc.101 and later), which are built from a private tree that adds the proprietary model crates (xerj-infer,xerj-serve,xerj-exec). This repository's source does not contain them: a node built frommainhas no/_factsroute, no--facts-model-dirflag and noxerj_facts_asktool. Everything below describes the release binaries.
What the model can do, with a verified example per capability: the capabilities overview, XERJ_QUERY_1.md.
What this file is: the shortest path from no model to a verified answer out of
/_facts. Last updated 2026-11-05 (rc.101). When this file and the
binary disagree, the binary wins (xerj --help). Background:
MODEL_BUNDLE.md (what the model directory is),
FACTS_API.md (the full request/response contract).
The model is XERJ Query-1, served on CPU. It answers facts and counting questions
over facts you have written to a namespace; it is not the search embedder
(search's default embedder is lexical feature-hashing, a separate thing). It is
off by default: without --facts-model-dir there is no /_facts route and no
model loads (rc.101 still upgrades the data directory format on first write).
Every step below ends with a check and the output you should see.
curl -fsSL https://xerj.org/get | sh # Linux / macOS
# Windows PowerShell: irm https://xerj.org/get.ps1 | iexCheck: xerj --version prints xerj v1.0.0-rc.101 (or later). If the shell says
command not found, the installer did not edit your profile — call it by full
path ($HOME/.local/bin/xerj) or export PATH="$HOME/.local/bin:$PATH".
The installer can fetch it for you (about 390 MiB to download, 462 MiB unpacked,
checksum-verified, into ~/.local/share/xerj/model):
curl -fsSL https://xerj.org/get | sh -s -- --with-modelOr download the release asset yourself, verify it, and unpack it:
curl -fsSL -O https://github.com/xerj-org/xerj/releases/download/v1.0.0-rc.101/xerj-model-bundle-v1-v1.0.0-rc.101.tar.gz
curl -fsSL -O https://github.com/xerj-org/xerj/releases/download/v1.0.0-rc.101/xerj-model-bundle-v1-v1.0.0-rc.101.tar.gz.sha256
sha256sum -c xerj-model-bundle-v1-v1.0.0-rc.101.tar.gz.sha256 # -> ...: OK
mkdir -p ~/xerj-model
tar -xzf xerj-model-bundle-v1-v1.0.0-rc.101.tar.gz -C ~/xerj-model --strip-components=1Check: the folder has a bundle.json and a facts/ directory.
jq -r .schema ~/xerj-model/bundle.json
# -> xerj-model-bundle-v1There is no serve subcommand: start the bare xerj process with
--facts-model-dir. That flag is what turns XERJ Query-1 on; without it the node
has no /_facts route. (XERJ_FACTS_MODEL_DIR=~/xerj-model is the environment
equivalent; the flag wins.) For a quick local trial use a dev node (--insecure,
no auth); for anything real, start with auth/TLS as the CLI reference describes.
A foreground boot can be awkward on some hosts — start it in the background and
poll, do not block on it.
xerj --facts-model-dir ~/xerj-model --insecure --data-dir ~/xerj-data &Check: the model loaded. The node loads the bundle in the background after
boot, so the first calls answer "not_loaded" — measured 3.5 s from boot to
"loaded" on a laptop-class x86_64. Poll:
until s=$(curl -s localhost:9200/_facts | jq -r '.model.state // .error.type'); [ -n "$s" ] && [ "$s" != not_loaded ]; do sleep 1; done; echo "$s"
# -> loaded (unavailable or xerj_query_not_enabled is an error: see below)
curl -s localhost:9200/_facts | jq '{state: .model.state, counting: .model.counting}'
# -> {"state": "loaded", "counting": {"state": "ready"}} (a plain facts export without a counting role reports COUNTING_OFF)(XERJ_FACTS_PRELOAD=0 skips the background load; the state then stays
not_loaded until your first _ask, which pays the 3-4 s once.) If you started
with --port N, use N in place of 9200 in every line on this page.
The loop stops on every state except not_loaded, so a bad start-up never
leaves it polling forever. If it prints xerj_query_not_enabled, the node was
started without the flag. If it prints unavailable, the model directory is
missing or failed a load check: curl -s localhost:9200/_facts | jq -r .model.error
names the file, and _ask answers 503 MODEL_UNAVAILABLE naming it. Point
--facts-model-dir at the directory that holds bundle.json, facts/ and
counting/, then restart: model errors are sticky until the node restarts.
The model answers only over the facts[] you write — a document is the
source text a fact quotes from, and a namespace with documents but no facts
answers UNKNOWN to everything. Write one document and two facts into a
namespace (here demo):
curl -s localhost:9200/_facts/demo/_bulk -H 'content-type: application/json' -d '{
"documents": [{"doc_id": "d1", "version": "v1",
"text": "Ana Bel is 170 cm tall. Ben Cor is 182 cm tall."}],
"facts": [
{"fact_id": "f1", "subject": "Ana Bel", "subject_id": "emp:1", "relation": "height", "kind": "number",
"value": "170", "unit": "cm", "doc_id": "d1", "version": "v1", "start": 11, "end": 14, "quote": "170"},
{"fact_id": "f2", "subject": "Ben Cor", "subject_id": "emp:2", "relation": "height", "kind": "number",
"value": "182", "unit": "cm", "doc_id": "d1", "version": "v1", "start": 35, "end": 38, "quote": "182"}
]
}' | jq '{committed}'
# -> {"committed": {"from_rev": 1, "to_rev": 3}}Check: curl -s localhost:9200/_facts/demo | jq '{revision, published_rev}'
reports the revision you just committed.
The rules the batch is checked against (any failure refuses the whole batch with
400 facts_contract_error and the store's message): version is a string;
kind is one of text, date, number, boolean (nothing else — string
and entity are Unsupported value kind); value is a string for text /
number ("170"), YYYY-MM-DD for date, JSON true/false for boolean;
a fact's doc_id + version must be in the same batch or already committed;
quote must equal text[start:end] exactly; subject_id is one stable id per
subject, shared by all of that subject's facts (optional for lookups, needed for
counting). The full table is in
FACTS_API.md.
A SQLite file, SQL dump, CSV/TSV or XLSX becomes facts in one command: one
subject per row (subject_id from the key column), one fact per column.
xerj autoindex hr.sqlite --facts hr --url http://127.0.0.1:9200Verify: the last lines read like hr/people: 1000 rows · key id · subject name · wrote 6000 facts (1000 new, …) (output of our test of the unreleased change on a 1,000-row table).
Run it again after the table changes: only changed rows are rewritten and removed rows are withdrawn.
curl -s localhost:9200/_facts/demo/_ask -H 'content-type: application/json' \
-d '{"question": "How tall is Ana Bel?"}' | jq '{final_status, final_answer, path}'
# -> {"final_status": "ANSWER", "final_answer": "170 cm", "path": "facts"}Read final_status and final_answer, not status/answer — the plain
fields are the model's unchecked program. A question the facts do not answer is
final_status: "UNKNOWN" (HTTP 200: a factual outcome, not an error); two facts
that disagree give CONFLICT. A counting question is served from the exact executor (path: "counting",
with program_sha256 and partner_agreement). Counting engages only on facts that carry subject_id: a plain "how many
have " compiles to a distinct count over
subject_id, and one counted subject without an id makes the result
INCOMPLETE, which the node reports as final_status: "UNKNOWN" with
path: "facts" (the executor does not guess, but a served count can still count the wrong set when the question is outside the op-set, for example an "or" question). Give every subject one stable id and put it on
every fact about that subject. The scope on rc.101 is set counts. Numeric thresholds
("more than 20 devices") are declined (NO_PROGRAM) and answer UNKNOWN. Sums and
totals are declined (FIELD_UNUSED) only when the store has the named relation;
otherwise they can be served as a member count. Why a count was not served is in
counting.status and counting.notes.declines of the path: "facts" response.
A count end to end, in a fresh namespace:
curl -s localhost:9200/_facts/team/_bulk -H 'content-type: application/json' -d '{
"documents":[{"doc_id":"d0","version":"v1","text":"Record Ana Bel.\noffice -> Berlin"},
{"doc_id":"d1","version":"v1","text":"Record Bo Chen.\noffice -> Berlin"},
{"doc_id":"d2","version":"v1","text":"Record Di Eve.\noffice -> Munich"}],
"facts":[{"fact_id":"f0","subject":"Ana Bel","subject_id":"emp:0","relation":"office","kind":"text","value":"Berlin","doc_id":"d0","version":"v1","start":26,"end":32,"quote":"Berlin"},
{"fact_id":"f1","subject":"Bo Chen","subject_id":"emp:1","relation":"office","kind":"text","value":"Berlin","doc_id":"d1","version":"v1","start":26,"end":32,"quote":"Berlin"},
{"fact_id":"f2","subject":"Di Eve","subject_id":"emp:2","relation":"office","kind":"text","value":"Munich","doc_id":"d2","version":"v1","start":25,"end":31,"quote":"Munich"}]}'
curl -s localhost:9200/_facts/team/_ask -H 'content-type: application/json' \
-d '{"question":"How many people have office Berlin?"}' | jq '{path, final_status, final_answer, agree: .counting.partner_agreement}'
# -> {"path": "counting", "final_status": "ANSWER", "final_answer": 2, "agree": true}Warning: a count tallies the members of the matched set and does not check the
noun of your question — "How many devices do the Berlin offices have in total?"
on this namespace is also served as 2 (people, not devices; sums are not
supported). Counting answers carry no evidence ids by design. Ask for the member
type you mean.
Do not confuse this with POST /_ask (no /_facts): that is the query planner
for _search, and a free-text question there answers 422 unresolved_phrase.
Check a historical question by revision — the engine does not infer history from
item_id, so name the revision:
curl -s localhost:9200/_facts/demo/_ask -H 'content-type: application/json' \
-d '{"question": "How tall is Ana Bel?", "revision": 1}' | jq '.final_answer'xerj mcp serves the xerj_facts_ask tool — a thin, read-only proxy of
POST /_facts/{ns}/_ask — when the node it talks to was started with
--facts-model-dir (it asks the node once at start-up; XERJ_MCP_FACTS=on|off
decides instead). Register the MCP server once (per client), then call it with
{"namespace": "demo", "question": "..."}.
- Claude Code:
xerj initwrites.mcp.jsonand printsclaude mcp add --scope user xerj -- "$(command -v xerj)" mcp. - Cursor / Windsurf / Claude Desktop / Cline — root key
mcpServers:{"mcpServers": {"xerj": {"command": "/abs/path/to/xerj", "args": ["mcp"], "env": {"XERJ_URL": "http://localhost:9200"}}}} - VS Code (
.vscode/mcp.json) — root keyservers(amcpServersblock is silently ignored):{"servers": {"xerj": {"type": "stdio", "command": "/abs/path/to/xerj", "args": ["mcp"]}}}
Check: after restarting the client, xerj_facts_ask is in the tool list. If
xerj_search is listed and xerj_facts_ask is not, the node xerj mcp reached
was started without --facts-model-dir (or was not up when xerj mcp started —
restart the client, or set XERJ_MCP_FACTS=on).