TiDB.Ecto.Fulltext.Query (tidb v0.1.0)

Copy Markdown View Source

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.Query

Example

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

fts_match_word(column, word)

(macro)

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