neosqlite.collection.temporary_table_aggregation.operators_text module

class neosqlite.collection.temporary_table_aggregation.operators_text.OperatorsTextMixin[source]

Bases: OperatorsBaseMixin

_process_text_search_stage(create_temp: Callable, current_table: str, match_spec: dict[str, Any]) str[source]

Process a $text search stage using FTS5 on temporary table.

This method creates an FTS5 virtual table on the temporary data and uses SQLite’s FTS5 for efficient text search. The tokenizer configuration is detected from the existing FTS index on the collection to ensure consistent behavior.

Note

When $text is used after $unwind (or other stages that create temp tables), the search operates on the unwound elements in the temp table, not on the original collection documents. This differs from MongoDB’s semantics where $text always uses the collection-level text index on original documents.

Parameters:
  • create_temp (Callable) – Function to create temporary tables

  • current_table (str) – Name of the current temporary table containing input data

  • match_spec (dict[str, Any]) – The $match stage specification containing the $text operator with a $search term

Returns:

Name of the newly created temporary table with text search results

Return type:

str

Raises:

ValueError – If the $text operator specification is invalid or the search term is not a string

_detect_fts_tokenizer() str[source]

Detect the tokenizer configuration from existing FTS indexes on the collection.

Returns:

The tokenizer clause for FTS5 (e.g., “, tokenize=porter” or “”)

Return type:

str