co3.accessors.fts module¶
- class co3.accessors.fts.FTSAccessor[source]¶
Bases:
Accessor
Perform queries on efficient full-text search (FTS) tables.
Note how this class doesn’t inherit from
SQLAccessor
, or evenRelationalAccessor
. We don’t look at FTS tables as Relations, due to restrictions on their JOIN capabilities, and avoid embracing what composability they may have to prevent accidentally introducing inefficiencies. Instead, just single FTS tables can be selected from via this Accessor, and the FTSTable type, despite the use of the word “table”, is a direct child of the Component type.- select(connection, table_name, select_cols='*', search_cols=None, query=None, col_query=None, snip_col=0, hl_col=0, limit=100, snip=64, tokenizer='unicode61')[source]¶
Execute a search query against an indexed FTS table for specific primitives. This method is mostly a generic FTS handler, capable of handling queries to any available FTS table with a matching naming scheme (
fts_<type>_<tokenizer>
). The current intention is support all tokenizers, for file, note, block, and link primitives.Search results include all FTS table columns, as well as SQLite-supported
snippet``s and ``highlight``s for matches. Matches are filtered and ordered by SQLite's ``MATCH
-based score for the text & column queries. Results are (a list of) fully expanded dictionaries housing column-value pairs.- Parameters:
table_name (
str
) – name of FTS table to searchsearch_cols (
str
|None
) – space separated string of columns to use for primary queriesq – search query
colq – column constraint string; must conform to SQLite standards (e.g.,
<col>:<text>
snip_col (
int
|None
) – table column to use for snippets (default: 1; source content column)hl_col (
int
|None
) – table column to use for highlights (default: 2; format column, applied to HTML targets)limit (
int
|None
) – maximum number of results to return in the SQL querysnip (
int
|None
) – snippet length (max: 64)tokenizer (
str
|None
) – tokenizer to use (assumes relevant FTS table has been built)
- Returns:
Dictionary with search results (list of column indexed dictionaries) and relevant metadata.