Improved query curation in release search function.
This commit is contained in:
parent
342d8da29b
commit
b4129891dc
|
@ -1024,7 +1024,7 @@ exports.up = knex => Promise.resolve()
|
||||||
SELECT releases.* FROM (
|
SELECT releases.* FROM (
|
||||||
SELECT
|
SELECT
|
||||||
releases_search.release_id,
|
releases_search.release_id,
|
||||||
ts_rank(releases_search.document, to_tsquery('english', array_to_string(regexp_split_to_array(query, E'\\s+'), '|'))) AS rank
|
ts_rank(releases_search.document, to_tsquery('english', regexp_replace(query, '[\\s._-]+', '|', 'gi'))) AS rank
|
||||||
FROM releases_search
|
FROM releases_search
|
||||||
) ranks
|
) ranks
|
||||||
LEFT JOIN releases ON releases.id = ranks.release_id
|
LEFT JOIN releases ON releases.id = ranks.release_id
|
||||||
|
|
|
@ -134,7 +134,7 @@ async function fetchScenes(limit = 100) {
|
||||||
|
|
||||||
async function searchScenes(query, limit = 100) {
|
async function searchScenes(query, limit = 100) {
|
||||||
const releases = await knex
|
const releases = await knex
|
||||||
.from(knex.raw('search_releases(?) as releases', [query]))
|
.from(knex.raw('search_releases(:query) as releases', { query }))
|
||||||
.modify(withRelations, false, true)
|
.modify(withRelations, false, true)
|
||||||
.limit(Math.min(limit, 1000000));
|
.limit(Math.min(limit, 1000000));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue