sqlalchemy_singlestoredb.FullTextIndex

class sqlalchemy_singlestoredb.FullTextIndex(*columns: str | Tuple[str, str], name: str | None = None, version: int | None = None)

SingleStore FULLTEXT INDEX DDL element.

Represents a FULLTEXT INDEX for full-text search on text columns, enabling efficient text search queries.

Parameters:
  • *columns (Union[str, Tuple[str, str]]) – Variable number of column specifications. Each can be: - A string (column name, defaults to ASC) - A tuple of (column_name, direction) where direction is ‘ASC’ or ‘DESC’ Must be text columns (CHAR, VARCHAR, TEXT, LONGTEXT).

  • name (str, optional, keyword-only) – Index name for the fulltext index. If not provided, SingleStore will auto-generate a name.

  • version (int, optional, keyword-only) – FULLTEXT version to use. Version 1 (default) if not specified. Version 2 or higher requires explicit specification.

Examples

Single column, auto-named:

>>> FullTextIndex('title')

Single column, named:

>>> FullTextIndex('title', name='ft_title')

Multiple columns, named:

>>> FullTextIndex('title', 'content', name='ft_search')

With sort directions:

>>> FullTextIndex('title', ('content', 'DESC'), name='ft_search')

With version specification:

>>> FullTextIndex('title', 'content', name='ft_v2', version=2)

Using static helper methods:

>>> FullTextIndex(FullTextIndex.asc('title'), FullTextIndex.desc('content'))

Table Usage:

from sqlalchemy import Column, Integer, MetaData, String, Table, Text
from sqlalchemy_singlestoredb import FullTextIndex
metadata = MetaData()
articles = Table(
    'articles', metadata,
    Column('id', Integer, primary_key=True),
    Column('content', Text),
    singlestoredb_full_text_indexes=[FullTextIndex('content')],
)
# Multiple columns with name
documents = Table(
    'documents', metadata,
    Column('id', Integer, primary_key=True),
    Column('title', String(200)),
    Column('body', Text),
    singlestoredb_full_text_indexes=[
        FullTextIndex('title', 'body', name='ft_doc_search'),
    ],
)

ORM Usage:

from sqlalchemy import Column, Integer, String, Text
from sqlalchemy.orm import declarative_base
from sqlalchemy_singlestoredb import FullTextIndex
Base = declarative_base()
class Article(Base):
    __tablename__ = 'articles'
    id = Column(Integer, primary_key=True)
    content = Column(Text)
    __table_args__ = {
        'singlestoredb_full_text_indexes': [FullTextIndex('content')],
    }
class Document(Base):
    __tablename__ = 'documents'
    id = Column(Integer, primary_key=True)
    title = Column(String(200))
    body = Column(Text)
    __table_args__ = {
        'singlestoredb_full_text_indexes': [
            FullTextIndex('title', 'body', name='ft_doc_search'),
        ],
    }
__init__(*columns: str | Tuple[str, str], name: str | None = None, version: int | None = None) None

Methods

__init__(*columns[, name, version])

against(target)

Return a copy of this _schema.ExecutableDDLElement which will include the given target.

asc(column)

Create an ascending fulltext index column specification.

compare(other, **kw)

Compare this _expression.ClauseElement to the given _expression.ClauseElement.

compile([bind, dialect])

Compile this SQL expression.

desc(column)

Create a descending fulltext index column specification.

execute_if([dialect, callable_, state])

Return a callable that will execute this _ddl.ExecutableDDLElement conditionally within an event handler.

execution_options(**kw)

Set non-SQL options for the statement which take effect during execution.

get_children(*[, omit_attrs])

Return immediate child visitors.HasTraverseInternals elements of this visitors.HasTraverseInternals.

get_execution_options()

Get the non-SQL options which will take effect during execution.

memoized_instancemethod(fn)

Decorate a method memoize its return value.

options(*options)

Apply options to this statement.

params([_ClauseElement__optionaldict])

Return a copy with _expression.bindparam() elements replaced.

self_group([against])

Apply a 'grouping' to this _expression.ClauseElement.

unique_params([_ClauseElement__optionaldict])

Return a copy with _expression.bindparam() elements replaced.

Attributes

allows_lambda

description

entity_namespace

inherit_cache

Indicate if this HasCacheKey instance should make use of the cache key generation scheme used by its immediate superclass.

is_clause_element

is_delete

is_dml

is_from_statement

is_insert

is_select

is_selectable

is_text

is_update

stringify_dialect

supports_execution

target

uses_inspection

name

columns

version

negation_clause

proxy_set