Inverted Index (Text Search)
Text search retrieves documents that contain specific terms or phrases from a dataset and ranks the results by relevance.
| Retrieval method | Strength | Applicable scenarios |
|---|---|---|
| Text search | "Find precisely": controllable, explainable exact matching that ensures deterministic keyword hits and filter conditions | Keyword search, phrase matching, boolean filtering |
| Vector search | "Find broadly": uses semantic similarity to expand the recall range | Semantic search, approximate matching |
In generative AI applications, especially in retrieval-augmented generation (RAG) scenarios, text search and vector search complement each other:
- Balance semantic breadth with lexical precision
- Improve recall while ensuring accuracy and explainability of results
- Together build a reliable retrieval foundation that provides more accurate and relevant context for large language models
Warning:
A future release is expected to restrict creation of V1 inverted indexes. For new tables, use a supported newer storage format. Before migrating existing V1 tables, ask VeloDB Cloud support to confirm the managed upgrade and rebuild requirements. Frontend configuration and process upgrades are managed by the service.
Text search capabilities
Inverted indexes support keyword and phrase queries, custom tokenization, relevance ranking with score(), and the SEARCH() DSL. These capabilities can be combined with vector retrieval. This guide describes behavior checked against VeloDB Core 26.1.3. The Core 26.1 series is in Public Preview.
Version applicability
Check your warehouse's Core release before choosing a feature. The following entries identify documented capabilities and changes. They do not establish the first supported release of every text-search feature.
| Capability or behavior | VeloDB Core release information |
|---|---|
| Custom analyzers | The VeloDB Core 4.1.4 release notes record custom analyzer support. This is a VeloDB Core version in the earlier VeloDB Core 4.1 series, not an Apache Doris version. See Custom Analyzer for the current pipeline and its limitations. |
| BM25 scoring and phrase queries | The Core 26.0.3 release notes describe BM25 and phrase-level scoring enhancements, plus prefix and phrase-prefix queries. |
Default SEARCH() parsing mode | Core 26.0.3 changed the default mode from standard to lucene. Set mode explicitly when your query depends on a particular Boolean interpretation. |
SEARCH() DSL, multi-field search, and Variant search | The Core 26.1.1 release notes describe these capabilities, including BM25 ranking. Earlier Core notes also mention SEARCH(), so Core 26.1.1 should not be interpreted as the first release of every SEARCH() capability. |
Custom IK tokenizers, configurable NGram size differences, and norms | Planned for Core 26.1.4. Confirm availability before using the planned features in Custom Analyzer and Relevance Scoring. |
Core text search features in VeloDB Cloud
1. Rich text operators
VeloDB Cloud provides a set of full-text search operators that cover multiple retrieval patterns, satisfying needs ranging from basic keyword matching to complex phrase queries.
Main operators supported in the current version:
| Operator | Description | Typical scenarios |
|---|---|---|
MATCH_ANY / MATCH_ALL | Any-term match (OR) and all-term match (AND) | General keyword search |
MATCH_PHRASE | Exact phrase match, with support for custom slop and order control | Proximity word queries |
MATCH_PHRASE_PREFIX | Phrase prefix match | Auto-completion, incremental search |
MATCH_REGEXP | Matching based on regular expressions | Pattern-based text retrieval |
These operators can be used independently or combined through the SEARCH() function to build complex logical queries. For example (the docs table referenced here is the one created in the Quick start section below):
-- Exact phrase search
SELECT * FROM docs WHERE content MATCH_PHRASE 'inverted index';
-- Prefix search
SELECT * FROM docs WHERE content MATCH_PHRASE_PREFIX 'data ware';
2. Custom tokenization
In text search, the tokenization method directly determines retrieval precision and recall. Use custom analyzers to define the tokenization pipeline for your search requirements. Creating analyzer components requires global ADMIN. If your warehouse SQL role does not have that privilege, contact VeloDB Cloud support.
Custom tokenization achieves fine-grained text control by combining the following three types of components:
- Character filter (
char_filter): Replaces, removes, or normalizes symbols before tokenization - Tokenizer (tokenizer): Selects the tokenization algorithm. Supports types such as
standard,ngram,edge_ngram,keyword, andicufor processing text in different languages and structures - Token filter (
token_filter): For example,lowercase,word_delimiter, andascii_folding, used to normalize and refine tokenization results
-- Example: Define a custom analyzer
CREATE INVERTED INDEX ANALYZER IF NOT EXISTS keyword_lowercase
PROPERTIES (
"tokenizer" = "keyword",
"token_filter" = "asciifolding, lowercase"
);
-- Table-definition fragment using the custom analyzer
CREATE TABLE docs (
id BIGINT,
content TEXT,
INDEX idx_content (content) USING INVERTED PROPERTIES(
"analyzer" = "keyword_lowercase",
"support_phrase" = "true"
)
);
Learn about custom tokenization
3. BM25 relevance scoring
VeloDB Cloud implements the BM25 (Best Matching 25) algorithm for text relevance computation, providing ranking and scoring capabilities for full-text search.
Core characteristics of BM25:
- A probabilistic model based on term frequency (TF), inverse document frequency (IDF), and document length
- Robust for both short and long texts
- Weighting strategy can be tuned through the
k1andbparameters
SELECT id, title, score() AS relevance
FROM docs
WHERE content MATCH_ANY 'real-time OLAP analytics'
ORDER BY relevance DESC
LIMIT 10;
Learn more about the scoring mechanism
4. SEARCH() function: unified query entry point
The SEARCH() function provides a unified syntax entry point for text retrieval, supporting multi-column search and boolean logic combinations, which makes complex queries more concise to express:
SELECT id, title, score() AS relevance
FROM docs
WHERE SEARCH('title:Machine AND tags:ANY(database sql)')
ORDER BY relevance DESC
LIMIT 20;
Complete SEARCH function guide
Quick start
Run the SQL in a test database where your SQL role can create tables, insert rows, and query data. The query results depend on the rows you load. Indexes and test data consume compute and storage. Drop the test table when finished.
Step 1: Create a table with inverted indexes
CREATE TABLE docs (
id BIGINT,
title STRING,
content STRING,
category STRING,
tags ARRAY<STRING>,
created_at DATETIME,
-- Text search indexes
INDEX idx_title(title) USING INVERTED PROPERTIES ("parser" = "chinese"),
INDEX idx_content(content) USING INVERTED PROPERTIES ("parser" = "chinese", "support_phrase" = "true"),
INDEX idx_category(category) USING INVERTED,
INDEX idx_tags(tags) USING INVERTED
)
DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES ("replication_num" = "1");
Step 2: Run text queries
-- Simple keyword search
SELECT * FROM docs WHERE content MATCH_ANY 'apache doris';
-- Phrase search
SELECT * FROM docs WHERE content MATCH_PHRASE 'full-text search';
-- Boolean query with SEARCH
SELECT * FROM docs
WHERE SEARCH('title:apache AND (category:database OR tags:ANY(sql nosql))');
-- Relevance-based ranking
SELECT id, title, score() AS relevance
FROM docs
WHERE content MATCH_ANY 'real-time analytics OLAP'
ORDER BY relevance DESC
LIMIT 10;
Hybrid search: Text + vector
In RAG applications, combine text search with vector similarity. The following is a query template: the earlier docs table does not define embedding. Add and populate an ARRAY<FLOAT> embedding column and replace the abbreviated query vector before using it:
-- Hybrid retrieval: semantic similarity + keyword filtering
SELECT id, title, score() AS text_relevance
FROM docs
WHERE
-- Vector filter for semantic similarity
cosine_distance(embedding, [0.1, 0.2, ...]) < 0.3
-- Text filter for keyword constraints
AND SEARCH('title:search AND content:engine AND category:technology')
ORDER BY text_relevance DESC
LIMIT 10;
Manage inverted indexes
Create an index
To index a column on an existing table, use CREATE INDEX. For example, add an index on the timestamp column of the docs table from the quick start:
CREATE INDEX idx_created_at ON docs(created_at) USING INVERTED;
Build indexes for existing data
In VeloDB Core 26.1.3, adding a tokenized inverted index, such as one with "parser" = "chinese", builds the index for existing rows through a schema change. Wait for the job to reach FINISHED before relying on the index for those rows:
SHOW ALTER TABLE COLUMN WHERE TableName = 'docs';
For a non-tokenized inverted index or an NGram BloomFilter index, the session variable enable_add_index_for_new_data controls when existing rows are indexed. Check its value with SHOW VARIABLES LIKE 'enable_add_index_for_new_data'. With the Core default of false, the schema change includes existing rows. Set it to true before creating the index to index new writes immediately and backfill older rows separately.
To try a deferred build, open a new session on an available cluster and run this example in a test database:
CREATE TABLE cloud_index_example (
id INT,
tag VARCHAR(64)
) DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 1;
INSERT INTO cloud_index_example VALUES (1, 'search'), (2, 'database');
SET enable_add_index_for_new_data = true;
CREATE INDEX idx_tag ON cloud_index_example(tag)
USING INVERTED PROPERTIES ("parser" = "none");
BUILD INDEX ON cloud_index_example;
SHOW BUILD INDEX WHERE TableName = 'cloud_index_example';
VeloDB Cloud requires the table name alone in BUILD INDEX ON and rejects a named-index build. Wait for SHOW BUILD INDEX to report FINISHED before using the index for historical rows. When finished testing, run DROP TABLE cloud_index_example and close the test session.
Drop an index
DROP INDEX idx_created_at ON docs;
View indexes
SHOW CREATE TABLE docs;
SHOW INDEX FROM docs;
Frequently asked questions
How can I tokenize Japanese text?
VeloDB Core 26.1.3 includes the icu and unicode parsers. It has no built-in Kuromoji tokenizer. Compare the tokens on representative text before choosing a parser for your index:
SELECT TOKENIZE('東京都で検索する', '"parser"="icu"');
SELECT TOKENIZE('東京都で検索する', '"parser"="unicode"');
Do text search operators correct spelling mistakes?
Text search operators support prefix matching, regular expressions, and phrase slop. Phrase slop allows variation in token positions. These operators do not expand a misspelling to terms within a given edit distance.
Further reading
Core documentation
- Text search operators: Complete operator reference and query acceleration
- SEARCH function: Unified query DSL syntax and examples
- Relevance scoring: Relevance ranking algorithm and usage
Advanced topics
- Custom analyzer: Build domain-specific tokenizers and filters
- Vector search: Use embedding vectors for semantic similarity search