Opened 7 months ago

Last modified 6 weeks ago

#28077 new New feature

Allow specifying an operator class for GinIndex()

Reported by: IzyJeepee Owned by:
Component: contrib.postgres Version: 1.11
Severity: Normal Keywords: postgres, gin, operator, class
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello,

I want use the GinIndex method to create a gin index with the django's migration. But while the migration, I have this errror :

django.db.utils.ProgrammingError : data type character varying has no default operator class for access method "gin"
HINT : You must specify an operator class ofr the index or define a default operator class for the data type.

This error may be resolved by enabling the btree_gin extension.

It is possible to pass the operator class during the index's creation ? For example :

class Meta:
    indexes = [
        GinIndex(fields=['my_field'], name='my_index_gin', operator_class='my_operator')
    ]

Thanks

Change History (4)

comment:2 Changed 7 months ago by Mads Jensen

#27437 looks like it's overlapping a little bit.

comment:3 Changed 7 months ago by Tim Graham

Summary: GinIndex() and operator classAllow specifying an operator class for GinIndex()
Triage Stage: UnreviewedAccepted

I don't have much expertise here about the use cases and how this might interact with #27437. Tentatively accepting for further investigation.

comment:5 Changed 6 weeks ago by vinay karanam

I've a use case where I am always doing __contains query on JSONField. So, I would prefer GIN index to be created using jsonb_path_ops operator class rather than the default jsonb_ops.

Note: See TracTickets for help on using tickets.
Back to Top