OriginChain docs
examples · fts · 2 / 6

2. Boolean search - single token

← FTS examples
what this does

Returns the doc_id of every document whose description contains the token wireless, as a bare JSON array of strings. No scoring is computed and no ordering is implied - this is a set, not a ranked list. Boolean is the default mode; you get it even if you omit mode.

when to use it
  • "Does any product mention X" - membership checks, not relevance.
  • Pre-filter step before a more expensive query (rank only the matched set).
  • Tag-style search where every match is equally important.

If you need ordering by relevance, use BM25 mode instead.

the request

Assumes you've indexed at least a few documents - see Example 1.

GET /v1/tenants/:t/fts/:schema/:field?q=...&mode=boolean
curl -G "https://$OC_HOST/v1/tenants/$OC_TENANT/fts/shop.products/description" \
  -H "Authorization: Bearer $OC_TOKEN" \
  --data-urlencode "q=wireless" \
  --data-urlencode "mode=boolean"
what you get back
["p001", "p014", "p027"]

The body is the array itself - there is no { "mode": ..., "doc_ids": [...] } wrapper. Parse it and iterate directly.

how it works
  • The query is tokenised with the same analyser used at index time - lowercased and split on whitespace/punctuation.
  • The single token is looked up in the inverted index. The posting list for that token is the answer.
  • Because there's no scoring step, boolean mode is the cheapest query shape - constant work per matching doc, no per-doc maths.
common mistakes
  • Expecting a ranked order. The returned array is sorted lexicographically by doc_id, not by relevance. Don't read any ranking into the order.
  • Looking for a .doc_ids field. The response is the bare array - ["p001", "p014"] - not an object. Accessing .doc_ids on it returns undefined.
  • Expecting case sensitivity. The query token is lowercased to match indexing - q=Wireless and q=wireless behave identically.
  • Passing multiple tokens and expecting OR. Multi-token boolean is AND - see the next example.