Skip to content

The match operator of text search - #284

Merged
tamnd merged 1 commit into
mainfrom
tsm
Oct 13, 2026
Merged

tamnd merged 1 commit into
mainfrom
tsm

Conversation

@tamnd

@tamnd tamnd commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

This adds the match operator @@ of text search for tsvector and tsquery, as ts_match_vq and TS_execute of tsvector_op.c have it. The functions that need a text search configuration, such as to_tsvector, are not in this change.

Changes

  • rupg-func has the new module tsmatch, with ts_match_vq and ts_match_qv. The operators @@ and @@@ use these functions in both argument orders.
  • An operand matches a lexeme with one of the weights of the operand. A lexeme with no positions matches each weight, as in PostgreSQL.
  • A prefix operand such as cat:* matches each lexeme that starts with the prefix. Under <N>, the positions of all these lexemes are merged.
  • The operator <N> follows TS_phrase_execute. It has the rules of PostgreSQL for !, & and | under <N>, and the width of a match.
  • A lexeme with no positions under <N> gives the result "maybe", as TS_MAYBE does. At the top of the query, <N> with this result does not match.
  • A position keeps 16 bits when the distances are added, as a WordEntryPos does. Thus a large <N> gives the same result as PostgreSQL.
  • An empty query matches no vector.

Tests

  • The session test ts_match is the output of PostgreSQL 19 for the same script in a new database. It has weights, prefixes, !, & and | inside and outside <N>, positions near the limit, vectors with no positions, GROUP BY on a match, @@@ and a query with parameters.
  • A unit test for the match of each type of operand and operator.
  • fmt, clippy, the workspace tests and the checks of xtask pass on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 13, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. gate/G1 G1: 7 clients connect and show the schema (L1, L2). area/types Types, type I/O, casts and collations. labels Oct 13, 2026
@tamnd tamnd self-assigned this Oct 13, 2026
@tamnd
tamnd merged commit deedd75 into main Oct 13, 2026
5 checks passed
@tamnd
tamnd deleted the tsm branch October 13, 2026 10:32
@tamnd tamnd mentioned this pull request Oct 13, 2026
8 of 15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/types Types, type I/O, casts and collations. gate/G1 G1: 7 clients connect and show the schema (L1, L2). kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant