Skip to main content
http://img.shields.io/travis/wagtail/wagtail-pg-search-backend/master.svg

A PostgreSQL full text search backend for Wagtail CMS.

Installation

PostgreSQL full text search in Wagtail requires PostgreSQL >= 9.2 (noticable speed improvements are in place for PostgreSQL >= 9.5), Django >= 1.10 and Wagtail >= 1.8.

First, install the module using:

pip install wagtail-pg-search-backend

Then you’ll need to do a little bit of configuration.

Add the following to the project settings:

INSTALLED_APPS = [
    ...
    'wagtail_pgsearchbackend'
    ...
]

WAGTAILSEARCH_BACKENDS = {
    'default': {
        'BACKEND': 'wagtail_pgsearchbackend.backend',
        'SEARCH_CONFIG': 'english'
    }
}

Then run migrations to add the required database table:

./manage.py migrate wagtail_pgsearchbackend

Configuration

The SEARCH_CONFIG key takes a text search configuration name. This controls the stemming, stopwords etc. used when searching and indexing the database. To get a list of the available config names use this query:

SELECT cfgname FROM pg_catalog.pg_ts_config

Usage

This backend implements the required methods to be compatible with most features mentioned in the the Wagtail search docs.

Known limitations

  • SearchField.partial_match behaviour is not implemented.

  • Due to a PostgreSQL limitation, SearchField.boost is only partially respected. It is changed so that there can only be 4 different boosts. If you define 4 or less different boosts, everything will be perfectly accurate. However, your search will be a little less accurate if you define more than 4 different boosts. That being said, it will work and be roughly the same.

  • SearchField.es_extra is not handled because it is specific to ElasticSearch.

  • Using SearchQuerySet.search while limiting to specific field(s) is only supported for database fields, not methods.

Performance

The PostgreSQL search backend has been tried and tested on a few small to medium sized website and its performance compares favorably to that of ElasticSearch.

Some noticeable speed improvements are in place when using PostgreSQL >= 9.5.

Features to add

These features would awesome to have once this project is merged with Wagtail:

  • Per-object boosting

  • Faceting

  • Autocomplete (maybe it should replace partial search?)

  • Spelling suggestions

Development

Install the package and dev requirements:

pip install -e . -r requirements-dev.txt

Creating migrations

First create a database:

createdb -Upostgres wagtail_pgsearchbackend

Then call makemigrations using the test settings:

django-admin makemigrations --settings=tests.settings

Testing

To run the unittests for the current environment’s Python version and Wagtail run:

make unittests

To check the code for style errors run:

make flaketest

To combine these tasks run:

make

To run the unittest against all supported versions of Python and Wagtail run:

tox

The tox run will also create a coverage report combining the results of all runs. This report is located in htmlcov/index.html.

To run individual tests by name use the runtests.py script and give the dotted path the the test module(s), class(es) or method(s) that you want to test e.g.:

./runtests.py tests.test_module.TestClass.test_method

Release files for wagtail-pg-search-backend 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-pg-search-backend 1.3.2
File Size Uploaded
wagtail-pg-search-backend-1.3.2.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-pg-search-backend 1.3.2
File Interpreter ABI Platform
wagtail_pg_search_backend-1.3.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 32.3 kB

Release files / wagtail-pg-search-backend-1.3.2.tar.gz

Download URL wagtail-pg-search-backend-1.3.2.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
afcd888c51b6c282ae13691e305cded93dbfbcd3c5bccc474eb6f4dbe4f188e6
BLAKE2b-256 checksum
How to use checksums
855b76e80ecd6d1d3eec2b12d2ca90682a1d6cfec0c5e2d70a21043f7fd2bfc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / wagtail_pg_search_backend-1.3.2-py2.py3-none-any.whl

Download URL wagtail_pg_search_backend-1.3.2-py2.py3-none-any.whl
Size 14.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ea35c908df83ffb581ac088b355d3e2977515a2d1ab50e98a01390d01fa2d573
BLAKE2b-256 checksum
How to use checksums
207e1e67eec6a0acd83cbcf88eb91cf03ded2c8fd271f2b53100696b2939b1da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.3.2 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page