外观
本页尚未翻译
本页内容仍为英文原文,源自官方文档 sql/dql/contains-tokens。中文翻译正在分批进行中。
CONTAINS_TOKENS
The contains_tokens() scalar function: an index-accelerated keyword predicate usable directly in WHERE.
Applies to: Embedded ❌, Enterprise ✅
sql
SELECT * FROM my_docs WHERE contains_tokens(text, 'fox jumps dog')contains_tokens(column, tokens) is true when column contains all the tokens in tokens, split on whitespace and punctuation. It is equivalent to an fts() match query with fuzziness off, AND semantics and the simple tokenizer -- reach for it when you need a keyword test in a WHERE clause and have no use for a relevance score.
Index-accelerated. When the column has a full-text index that suits the query, the planner uses it instead of scanning, which is the reason to prefer it over LIKE or contains for keyword tests. See EXPLAIN to confirm the plan uses the index.