Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.1: sql,tsearch: add default_text_search_config and ts_rank #99323

Merged

Conversation

jordanlewis
Copy link
Member

@jordanlewis jordanlewis commented Mar 23, 2023

Backports #97685 #97697.

Updates: #41288
Epic: CRDB-22357
Release justification: low risk missing piece from net new functionality

These just missed the cut. Entirely new functionality, low risk to existing code.

This commit adds the default_text_search_config variable for the tsearch
package, which allows the user to set a default configuration for the
text search builtin functions that take configurations, such as
to_tsvector and to_tsquery. The default for this configuration variable
is 'english', as it is in Postgres.

Release note (sql change): add the default_text_search_config variable
for compatibility with the single-argument variants of the text search
functions to_tsvector, to_tsquery, phraseto_tsquery, and
plainto_tsquery, which use the value of default_text_search_config
instead of expecting one to be included as in the two-argument variants.
The default value of this setting is 'english'.
@jordanlewis jordanlewis requested review from rytaft and a team March 23, 2023 00:44
@jordanlewis jordanlewis requested a review from a team as a code owner March 23, 2023 00:44
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add the release-23.1 label to the PR name

:lgtm:

Reviewed 14 of 14 files at r1, 10 of 10 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jordanlewis)


pkg/util/tsearch/tsquery.go line 508 at r2 (raw file):

			if stopWord {
				foundStopwords = true
				//continue

Didn't notice this in the original PR -- looks like a leftover?

@jordanlewis jordanlewis changed the title sql,tsearch: add default_text_search_config and ts_rank release-23.1: sql,tsearch: add default_text_search_config and ts_rank Mar 23, 2023
This commit adds ts_rank, the family of builtins that allow ranking of
text search results. The function takes a tsquery and a tsvector and
returns a float that indicates how good the match is. The function can
be modified by passing in a custom array of weights that matches the
text search weights A, B, C, and D, and a bitmask that controls the
ranking behavior in various detailed ways.

See the excellent Postgres documentation here for details:
https://www.postgresql.org/docs/current/textsearch-controls.html

Release note (sql change): add the ts_rank function for ranking text
search query results
@jordanlewis jordanlewis force-pushed the backport23.1-97685-97697 branch from 39f0188 to da1f1ef Compare March 23, 2023 01:17
@jordanlewis
Copy link
Member Author

Done, and oops, what happened there was that the version that you reviewed was missing a small change that went along with a test update that did make it in (ensuring that to_tsquery('text with only stop words') successfully errors). The test update made it in, the change that causes the test to pass didn't, and that change included a commented out continue rather than no continue at all which is the correct behavior.

Opened #99324 to fix the skew from master.

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jordanlewis)

@jordanlewis jordanlewis merged commit 39a47ac into cockroachdb:release-23.1 Mar 23, 2023
@jordanlewis jordanlewis deleted the backport23.1-97685-97697 branch March 23, 2023 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants