neosqlite.collection.temporary_table_aggregation.operators_text module¶
- class neosqlite.collection.temporary_table_aggregation.operators_text.OperatorsTextMixin[source]¶
Bases:
OperatorsBaseMixin- _matches_text_search(document: dict[str, Any], search_term: str) bool[source]¶
Apply Python-based text search to a document.
This method uses the unified_text_search function to determine if a document matches a given search term. It’s used as a fallback when text search cannot be efficiently handled with SQL queries, particularly in cases involving unwound elements or complex text search operations.
- Parameters:
document (dict[str, Any]) – The document to search in
search_term (str) – The term to search for
- Returns:
True if the document matches the text search, False otherwise
- Return type:
bool
- _batch_insert_documents(table_name: str, documents: list[tuple]) None[source]¶
Insert multiple documents into a temporary table efficiently.
This method provides an optimized way to insert multiple documents into a temporary table by using a single INSERT statement with multiple value sets. It’s used primarily in the text search processing where documents need to be filtered and inserted into a result table.
- Parameters:
table_name (str) – The name of the table to insert into
documents (list[tuple]) – List of (id, data) tuples to insert
- _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