Skip to content

Resolve "Switch to proper full-text-search system"

Agate requested to merge 994-full-text-search into develop

Closes #994 (closed)

I initially pushed on develop by mistake so I had to revert then rerevert…

Anyway, this leveragaes django and PostgreSQL Full-Text-Search capabilities (https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/search/#searchvectorfield):

  1. Add a new body_text column on artists, albums, and tracks, with a tsvector type
  2. Populate this field with adequate data from the corresponding objects (title for tracks and albums, name for artists)
  3. Use this new field for our search (instead of the %LIKE% queries spanning multiple fields we had before
  4. Enjoy the performance improvements (between x2 and x5 in terms of speed during my local tests, possibly even higher on more modest hardware or bigger databases).

I also add to add database triggers on Postgresql to ensure the body_text field is synchronized properly whenever an object is updated.

Sidenote: I've included some new tests for the search endpoint (it wasn't covered), and a feature flag to ensure we can revert back to the old logic in case anything goes wrong.

Edited by Agate

Merge request reports