FlureeLabs

fluree context

Manage the default JSON-LD context for a ledger.

Usage

fluree context <COMMAND>

Subcommands

CommandDescription
get [LEDGER]Show the default JSON-LD context
set [LEDGER]Replace the default JSON-LD context

Description

Each ledger can have a default context — a JSON object mapping prefixes to IRIs (e.g., {"ex": "http://example.org/"}). When a JSON-LD query is sent via the CLI and omits its own @context, the ledger's default context is injected automatically. The HTTP API requires ?default-context=true to opt in per request, and fluree-db-api requires explicit opt-in via its default-context view builders.

Default context is populated automatically during bulk import (from Turtle @prefix declarations). This command allows reading or replacing it after the fact.

The context is stored in content-addressed storage (CAS) and referenced from the nameservice config. Updates use compare-and-set semantics, so concurrent writers are safely handled.

context get

Show the current default context.

fluree context get [LEDGER]
ArgumentDescription
[LEDGER]Ledger name (defaults to active ledger)

Examples

# Show context for active ledger
fluree context get

# Show context for a specific ledger
fluree context get mydb

Output (pretty-printed JSON):

{
  "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
  "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
  "xsd": "http://www.w3.org/2001/XMLSchema#",
  "owl": "http://www.w3.org/2002/07/owl#",
  "ex": "http://example.org/"
}

If no default context has been set, a message is printed to stderr.

context set

Replace the default context with a new JSON object.

fluree context set [LEDGER] [OPTIONS]
ArgumentDescription
[LEDGER]Ledger name (defaults to active ledger)
OptionDescription
-e, --expr <JSON>Inline JSON context
-f, --file <PATH>Read context from a JSON file

If neither -e nor -f is provided, context is read from stdin.

The body can be either a bare JSON object or wrapped in {"@context": {...}} — both forms are accepted.

Examples

# Set inline
fluree context set mydb -e '{"ex": "http://example.org/", "foaf": "http://xmlns.com/foaf/0.1/"}'

# Set from file
fluree context set mydb -f context.json

# Pipe from stdin
cat context.json | fluree context set mydb

# Wrapped form also accepted
fluree context set mydb -e '{"@context": {"ex": "http://example.org/"}}'

See Also