Enable Full Text Search

djWarehouse comes with predefined full text search capabilities, but those are not enabled by default due to difficulties of full text search configuration in Postgres. Postgres needs superuser permissions for full text search (tsearch2.sql) so we do not want to enable this by default since normal users would not be able to use it without administrator privileges.

Enabling full text search in PostgreSQL

  • Create your database usual way
  • Find tsearch2.sql SQL script which is contributed with your PostgreSQL tsearch2 module. Execute it on your database but under superuser permissions:
   cat /usr/share/postgresql/contrib/tsearch2.sql | psql your_database -U postgres
  • Grant your user permissions to use full text index functions:
  GRANT SELECT ON pg_ts_dict to dbuser;
  GRANT SELECT ON pg_ts_parser to dbuser;
  GRANT SELECT ON pg_ts_cfg to dbuser;
  GRANT SELECT ON pg_ts_cfgmap to dbuser;
  • Add djWarehouse postgreSQL tsearch indexes:
  cat contrib/FullTextSearch/product.postgresql_psycopg2.sql | ./manage.py dbshell
  • Change urls.py to point to search_fulltext function.

Enabling full text index in MySQL

  • Create database usual way
  • Execute contrib/FullTextSearch/product.mysql.sql
  • Change urls.py to point to search_fulltext function.