mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Migration of text search related functions. ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request introduces a new text search utility using RUM indexes for BSON data. - Added `bson_dollar_text`, `bson_text_tsquery`, and `bson_text_meta_qual` functions in `sql/udfs/query/bson_dollar_text--1.24-0.sql` and `sql/udfs/query/bson_dollar_text--latest.sql`. - Created `bson_rum_text_path_ops` operator class in `sql/udfs/rum/bson_rum_text_path_ops--1.24-0.sql` and `sql/udfs/rum/bson_rum_text_path_ops--latest.sql`. - Added `rum_bson_single_path_extract_tsvector` and `rum_bson_text_path_options` functions in `sql/udfs/rum/bson_rum_text_path_funcs--1.24-0.sql` and `sql/udfs/rum/bson_rum_text_path_funcs--latest.sql`. - Updated regression tests in `src/test/regress/expected/bson_index_truncation_index_tests.out` and `src/test/regress/expected/public_api_schema.out`. - Modified `Makefile` to include the RUM extension in `src/test/regress/Makefile` and `pg_helio_api/src/test/regress/Makefile`.
40 lines
1.9 KiB
SQL
40 lines
1.9 KiB
SQL
|
|
|
|
-- dummy function that accepts the query planner phase, and exists only to handle the support function handling
|
|
-- to push down to the index.
|
|
CREATE OR REPLACE FUNCTION helio_api_internal.bson_dollar_text(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
COST 10000000000 -- really dissuade the planner from using this and force the index.
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_text$function$;
|
|
|
|
-- dummy function that exists to support the index operator (below). Needs to be separate from above due to the
|
|
-- 'tsquery' being an input. We can't generate the tsquery during the planning phase as we must use the default_language
|
|
-- in the index definition as STOP words defaults. Consequently the planner generates the function above, then the support
|
|
-- generates the operator below.
|
|
CREATE OR REPLACE FUNCTION helio_api_internal.bson_text_tsquery(__CORE_SCHEMA__.bson, tsquery)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_text$function$;
|
|
|
|
-- This is a function that tracks the input tsquery, and the index options associated with it so that $meta queries
|
|
-- can be made to work - injected during the plan phase.
|
|
-- Also used to do a runtime $text scan if necessary.
|
|
CREATE OR REPLACE FUNCTION helio_api_internal.bson_text_meta_qual(__CORE_SCHEMA__.bson, tsquery, bytea, bool)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_text_meta_qual$function$;
|
|
|
|
|
|
DROP FUNCTION IF EXISTS helio_api_internal.bson_query_to_tsquery;
|
|
|
|
-- This is a diagnostic query used to test translation of $text search clauses to TSQuery in Postgres.
|
|
CREATE OR REPLACE FUNCTION helio_api_internal.bson_query_to_tsquery(query __CORE_SCHEMA__.bson, textSearch text default NULL)
|
|
RETURNS tsquery
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE
|
|
AS 'MODULE_PATHNAME', $function$command_bson_query_to_tsquery$function$; |