跳到主要内容

Full-Text Search Functions

This section provides reference information for the full-text search functions in Databend. These functions enable powerful text search capabilities similar to those found in dedicated search engines.

信息

Databend's full-text search functions are inspired by Elasticsearch Full-Text Search Functions.

Search Functions

FunctionDescriptionExample
MATCHSearches for documents containing specified keywords in selected columnsMATCH('title, body', 'technology')
QUERYSearches for documents satisfying a specified query expression with advanced syntaxQUERY('title:technology AND society')
SCOREReturns the relevance score of search results when used with MATCH or QUERYSELECT title, SCORE() FROM articles WHERE MATCH('title', 'technology')

Usage Examples

-- Search for documents with 'technology' in title or body columns
SELECT * FROM articles
WHERE MATCH('title, body', 'technology');

Advanced Query Expressions

-- Search for documents with 'technology' in title and 'impact' in body
SELECT * FROM articles
WHERE QUERY('title:technology AND body:impact');

Relevance Scoring

-- Search with relevance scoring and sorting by relevance
SELECT title, body, SCORE()
FROM articles
WHERE MATCH('title^2, body', 'technology')
ORDER BY SCORE() DESC;

Before using these functions, you need to create an inverted index on the columns you want to search:

CREATE INVERTED INDEX idx ON articles(title, body);
开始使用 Databend Cloud
低成本
快速分析
多种数据源
弹性扩展
注册