jaimz22 / DoctrineFullTextPostrgres

A simple to use set of database types, and annotations to use postgresql's full text search engine with doctrine
17 stars 21 forks source link

Support generated columns in postgres 12 #25

Open tacman opened 2 years ago

tacman commented 2 years ago

https://www.postgresql.org/docs/current/ddl-generated-columns.html

full text search seems like a perfect use of generated columns, e.g.

ALTER TABLE se_details ADD COLUMN ts tsvector GENERATED ALWAYS AS (to_tsvector('english', event_narrative)) STORED;

Since the column with automatically sync with the source data.

I got this idea from

https://blog.crunchydata.com/blog/postgres-full-text-search-a-search-engine-in-a-database

If we bump the minimum up to PHP8 for version 2, we could add attributes in the Entity definition

#[FullText(index: 'main')]

We could then hook into the doctrine migrations and generate a migration that created the proper index.

Then instead of having

@TsVector(name="fts", fields={"name", "city"})

We could tag the name and city properties with the index name, and generate a migration and changed the index accordingly. The seems like it'd a much better DX.