我已经为我的数据库添加了GIN索引。
ALTER TABLE mtn_order
ADD COLUMN textsearchable_index_col tsvector
GENERATED ALWAYS AS (to_tsvector('english', coalesce(descr, '') || ' ' || coalesce(descrrep, ''))) STORED;
CREATE INDEX textsearch_idx ON mtn_order USING GIN (textsearchable_index_col);
我将
textsearchable_index_col = SearchVectorField(null=True)
添加到我的模型中,现在当我尝试保存新实例时,会出现以下错误:ProgrammingError at /order/create/
cannot insert into column "textsearchable_index_col"
DETAIL: Column "textsearchable_index_col" is a generated column.
如何阻止Django尝试将
None
写入该字段
GENERATED AS
功能的票并将其标记为重复,并指向我之前链接的票。例如:https://code.djangoproject.com/ticket/31565 和 https://code.djangoproject.com/ticket/31300。 - jorf.brunning