Full-text search query macros for TiDB in Ecto queries.
TiDB supports full-text search (FTS) indexes accelerated by TiFlash. This module provides query macros wrapping TiDB's full-text matching functions.
[!NOTE] Full-text search requires a table with a TiFlash replica and a full-text index created using
TiDB.Ecto.Migrations.fulltext_index/3.
Importing
import Ecto.Query
import TiDB.Ecto.Fulltext.QueryExample
from(a in MyApp.Article,
where: fts_match_word(a.body, "database"),
select: %{id: a.id, title: a.title}
)
|> MyApp.Repo.all()
Summary
Functions
Generates a full-text search word match condition using TiDB's FTS_MATCH_WORD function.
Functions
Generates a full-text search word match condition using TiDB's FTS_MATCH_WORD function.
Translates to the SQL fragment:
FTS_MATCH_WORD(<word>, <column>)Arguments
column- The text column on which a full-text index has been defined.word- The word or keyword expression to match against.
Examples
from a in Article,
where: fts_match_word(a.content, "elixir"),
select: a