surfacesimilaritymeans
Similarityscalar · returns boolean

MEANS

Returns TRUE if text semantically matches the criterion (cross-encoder)

Per-row — runs once for each row.

similarityrerankerspecialist-zootext

Syntax

{{ text }} MEANS {{ criterion }}
{{ text }} MATCHES {{ criterion }}

Arguments

nametypedescription
textVARCHAR
criterionVARCHAR
threshold(optional)DOUBLE

About

Semantic boolean filter — returns TRUE if text semantically matches the criterion. Powers the MEANS / MATCHES infix operators in WHERE clauses. Backend: specialist zoo cross-encoder (bge-reranker-v2-m3). Each row is scored in a single sub-millisecond encoder call against the criterion, then thresholded into a boolean. No LLM in the hot path. The threshold is calibrated to the sigmoid-normalized [0, 1] score the zoo /rerank endpoint returns. 0.5 is the neutral midpoint — tune with the `threshold` argument if your domain wants stricter or looser matching. If you need LLM-style contextual reasoning (world knowledge, implicit meaning, multi-step inference) rather than encoder-style topical similarity, use MEANS_LLM instead — see matches_llm.cascade.yaml.

Examples

Infix MEANS: matches related content

WITH
  t AS (
    SELECT
      'apple pie recipe' AS text
  )
SELECT
  *
FROM
  t
WHERE
  text MEANS 'dessert recipes'

Infix MATCHES: filters by semantic match

WITH
  t AS (
    SELECT
      'customer complaint about shipping delay' AS msg
  )
SELECT
  *
FROM
  t
WHERE
  msg MATCHES 'delivery issues'

Function: returns true for semantic match

SELECT
  semantic_matches ('renewable energy investments', 'clean energy')

Function: returns false for unrelated topics

SELECT
  semantic_matches ('basketball game results', 'cooking recipes')

Infix MEANS: returns false for unrelated topics

WITH
  t AS (
    SELECT
      'weather forecast' AS text
  )
SELECT
  CASE
    WHEN text MEANS 'financial news' THEN 'yes'
    ELSE 'no'
  END
FROM
  t

Function with compound expr: a || b concatenation

WITH
  t AS (
    SELECT
      'renewable energy' AS a,
      ' investments' AS b
  )
SELECT
  semantic_matches (a || b, 'clean energy')
FROM
  t

Function with COALESCE: handles NULL fallback

WITH
  t AS (
    SELECT
      NULL::VARCHAR AS a,
      'solar panel installations' AS b
  )
SELECT
  semantic_matches (COALESCE(a, b), 'clean energy')
FROM
  t

Function with CASE expression

WITH
  t AS (
    SELECT
      'renewable energy' AS text,
      1 AS flag
  )
SELECT
  semantic_matches (
    CASE
      WHEN flag = 1 THEN text
      ELSE 'nothing'
    END,
    'clean energy'
  )
FROM
  t

Nearby rabbit holes

same domain
Climb back to The Looking Glass