OriginChainDB
Multi-model writes

Find an article by words or meaning

← Multi-model writes

The language tabs use earlier client interfaces. Check SDK versions and connection setup before running them.

Store an article row, embedding and searchable body. Shared IDs let either search path open the original article.

Before you run it: These are separate writes. Update each affected representation when the article changes.

Use the tenant-scoped HTTP connection described in the connection notes. In these snippets, ORIGINCHAIN_URL is the origin including https://, T is its tenant ID, and OC_TOKEN is its bearer token. Do not append these routes to a different Connect URL format.

Search an article and open the sourceKeep the source, embedding and text index in sync when an article changes.
  1. Save the articleStore its title, body and source URL.
  2. Prepare two searchesWrite a title-and-body embedding and index the body text.
  3. Find its shared IDSearch by wording or meaning.
  4. Open the articleUse the ID to read the original content and URL.

Follow the example

  1. Register the schema.
  2. Write the article row.
  3. Write embedding and text with its ID.
  4. Search, then fetch the source row.

Set up the table

Plain row schema - no [[relations]] because there's no graph edge to write.

# kb/articles.toml
namespace   = "kb"
table       = "articles"
primary_key = ["id"]

[[columns]]
name = "id"
ty   = "str"
required = true

[[columns]]
name = "title"
ty   = "str"
required = true

[[columns]]
name = "body"
ty   = "str"
required = true

[[columns]]
name = "url"
ty   = "str"

[[columns]]
name = "created_ms"
ty   = "u64"

[[indexes]]
name    = "by_created"
columns = ["created_ms"]

The row

curl -X POST "$ORIGINCHAIN_URL/v1/tenants/$T/rows/kb.articles" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id":         "kb-2026-001",
    "title":      "How atomic multi-shape writes work",
    "body":       "Each shape (row, vector, FTS, graph) has its own endpoint. Every call is atomic individually. Retry behavior depends on the endpoint and key reuse.",
    "url":        "/docs/concepts/atomic-multi-shape",
    "created_ms": 1747900000000
  }'

The embedding (title + body concatenated)

Embed both fields together. A title-only embedding misses everything the body says, and that's where most of the meaningful tokens live.

curl -X POST "$ORIGINCHAIN_URL/v1/tenants/$T/vector/kb.articles/put" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id":        "kb-2026-001",
    "embedding": [0.0211, -0.0612, 0.0341, /* ... 768 floats ... */],
    "dim":       768,
    "metric":    "cosine"
  }'

The keyword index (body only)

Index the body for BM25 keyword search. Help-center queries are usually keyword-shaped ("install on Windows").

curl -X POST "$ORIGINCHAIN_URL/v1/tenants/$T/fts/kb.articles/body" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "doc_id": "kb-2026-001",
    "text":   "Each shape (row, vector, FTS, graph) has its own endpoint. Every call is atomic individually. Retry behavior depends on the endpoint and key reuse."
  }'

The embedding arrays are shortened illustrations. Generate the full vector with your chosen model, match dim to its length, and use that same model when embedding a search question. An embedding is a numeric representation used to compare meaning; OriginChainDB does not generate it in these write calls.

Handle separate writes and retries

These write calls commit separately. The documented SDKs do not provide automatic retry safety. A new SDK call can generate a new key. Retry reads with bounded backoff; for writes, confirm the endpoint supports deduplication and reuse a stable key, or reconcile the previous outcome first. See idempotency.

Important limits and checks

  • Embedding only the title. Concatenate title + body before embedding so semantic similarity fires on body content, not just the headline.
  • Indexing the title in FTS but not the body. The opposite mistake. The body is where the searchable keywords live.
  • Forgetting to re-index on update. If you edit an article, you have to re-put the row, re-put the vector, and re-index the FTS field. None of the three rides along with the others.
  • Embedding huge bodies as one vector. For long articles, split the body into passages, write one row per passage with a parent article_id, and embed each passage separately. Choose the passage size using your model's limits and retrieval tests.

Expected result

Adapt word search or vector search to kb.articles. Both paths use kb-2026-001 to identify this sample. Read that row to obtain the title, body and URL; the search result is not itself the full article.

Continue

Continue to filter events and search their text.

© 2026 Silicoyn Technologies Pvt Ltd

On this page