Skip to content

add configurable full-text search language - #11

Closed
alexandrusavin wants to merge 2 commits into
mainfrom
feat/configurable-fulltext-language
Closed

alexandrusavin wants to merge 2 commits into
mainfrom
feat/configurable-fulltext-language

Conversation

@alexandrusavin

Copy link
Copy Markdown

Summary

  • add a database-level full_text_search_language setting that defaults to english
  • use the configured PostgreSQL text search config consistently for chunk and document indexing plus full-text query execution
  • add unit coverage for language validation and configured full-text query generation, and document the default in sample configs

text TEXT,
metadata JSONB,
fts tsvector GENERATED ALWAYS AS (to_tsvector('english', text)) STORED
fts tsvector GENERATED ALWAYS AS (to_tsvector({self.full_text_search_regconfig}, text)) STORED

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changing the full_text_search_regconfig will require running a database schema migration. I guess that is missing?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We could also raise if someone tries to change the config retroactively.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We are not changing the schema, but only how the index is precomputed. We don't have to do a migration. I also spoke with Alex, and they'll have to re-upload the data to the instances they want to change from English.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We were changing the schema actually 😇

return "'" + value.replace("'", "''") + "'"


def psql_regconfig_literal(value: str) -> str:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this necessary? Are we guarding against someone putting an invalid config value?

ts_rank_cd(
setweight(to_tsvector('english', {metadata_fields_expr}), 'A'),
websearch_to_tsquery('english', $1),
setweight(to_tsvector({self.full_text_search_regconfig}, {metadata_fields_expr}), 'A'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not just pass the config value verbatim?

@grainnemcknight grainnemcknight left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Drive-by comment to ask what the plan is for language support and do we have a backlog item for it because it might bite us in butt per thread here?

We may want to do some language detection at ingestion time and store or maybe if we want to have a muli-language index.

Maybe we ignore this as we will anyway be retiring R2R?

@alexandrusavin

Copy link
Copy Markdown
Author

Drive-by comment to ask what the plan is for language support and do we have a backlog item for it because it might bite us in butt per thread here?

Alex was asking for the language so we can add it to the R2R config once we deploy this.

We may want to do some language detection at ingestion time and store or maybe if we want to have a muli-language index.

Yes, that was my first thought also, but it is a larger undertaking.

Maybe we ignore this as we will anyway be retiring R2R?

We won't be retiring R2R that soon it seems. Now that we can deploy our own R2R, I think we could fix some low-hanging anoying fruits.

Later update: https://interloom-io.slack.com/archives/C05RRLYGW0N/p1773332039460999?thread_ts=1773322061.599269&cid=C05RRLYGW0N

@alexandrusavin

Copy link
Copy Markdown
Author

Close in favor of waiting to see if maybe we don't have a problem 🤷 .
See this Slack thread.

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.

4 participants