jpadilla / notaso

Conoce a tus profesores antes de llegar al salón.
http://www.notaso.com/
Other
19 stars 6 forks source link

Replace djorm-ext-pgfulltext with django.contrib.postgres #104

Closed rnegron closed 6 years ago

rnegron commented 6 years ago

I replaced djorm’s VectorField and SearchManager with built-in solutions for handling full text search in Postgres. To do this, I added a post_save signal for the Professors app that takes care of updating the search_index using the update() method on the queryset. The djorm extension also handled auto-updating the search index with a post_save signal.

The SearchManager in djorm-ext-pgfulltext basically worked by adding an update_search_field method on the model class during model set up. It then ran a raw SQL query to keep the column up-to-date when auto_update_search_field was True.

I wasn't sure if making a new field was necessary, so I just updated the existing search_index field.

I also implemented a GIN index on the search_index field based on recommendations from this comment: https://news.ycombinator.com/item?id=16086489. As I understand it, adding an extension to the Postgres DB may be required to use the GIN index.

Also, I didn't uninstall djorm-ext-pgfulltext from the Pipfile since there is a migration which references the package...

jpadilla commented 6 years ago

@rnegron thanks again for this! just deployed and ran all migrations, everything seems to be working fine.