forked from DebaucheryLibrarian/traxxx
Refactored PG search function to allow superflous words in search query.
This commit is contained in:
parent
3ad1f3d1e3
commit
7818328378
|
@ -108,7 +108,6 @@ export default {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
||||||
grid-gap: 0 .5rem;
|
grid-gap: 0 .5rem;
|
||||||
flex-grow: 1;
|
|
||||||
margin: 0 0 1rem 0;
|
margin: 0 0 1rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ function initUiActions(_store, _router) {
|
||||||
releases: searchReleases(
|
releases: searchReleases(
|
||||||
query: $query
|
query: $query
|
||||||
first: $limit
|
first: $limit
|
||||||
|
minimalRank: "0.025"
|
||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
|
|
@ -1012,7 +1012,7 @@ exports.up = knex => Promise.resolve()
|
||||||
.then(() => { // eslint-disable-line arrow-body-style
|
.then(() => { // eslint-disable-line arrow-body-style
|
||||||
// allow vim fold
|
// allow vim fold
|
||||||
return knex.raw(`
|
return knex.raw(`
|
||||||
CREATE FUNCTION search_releases(query text) RETURNS SETOF releases AS $$
|
CREATE FUNCTION search_releases_legacy(query text) RETURNS SETOF releases AS $$
|
||||||
SELECT * FROM releases WHERE releases.id IN (
|
SELECT * FROM releases WHERE releases.id IN (
|
||||||
SELECT release_id FROM releases_search AS search
|
SELECT release_id FROM releases_search AS search
|
||||||
WHERE search.document @@ plainto_tsquery('traxxx', regexp_replace(query, '\\.|-|(XXX\\.[\\d+|hd|sd].*$)', ' ', 'ig'))
|
WHERE search.document @@ plainto_tsquery('traxxx', regexp_replace(query, '\\.|-|(XXX\\.[\\d+|hd|sd].*$)', ' ', 'ig'))
|
||||||
|
@ -1020,6 +1020,18 @@ exports.up = knex => Promise.resolve()
|
||||||
);
|
);
|
||||||
$$ LANGUAGE SQL STABLE;
|
$$ LANGUAGE SQL STABLE;
|
||||||
|
|
||||||
|
CREATE FUNCTION search_releases(query text, minimum_rank numeric DEFAULT 0) RETURNS SETOF releases AS $$
|
||||||
|
SELECT releases.* FROM (
|
||||||
|
SELECT
|
||||||
|
releases_search.release_id,
|
||||||
|
ts_rank(releases_search.document, to_tsquery('english', array_to_string(regexp_split_to_array(query, E'\\s+'), '|'))) AS rank
|
||||||
|
FROM releases_search
|
||||||
|
) ranks
|
||||||
|
LEFT JOIN releases ON releases.id = ranks.release_id
|
||||||
|
WHERE ranks.rank > minimum_rank
|
||||||
|
ORDER BY ranks.rank DESC;
|
||||||
|
$$ LANGUAGE SQL STABLE;
|
||||||
|
|
||||||
CREATE FUNCTION search_entities(search text) RETURNS SETOF entities AS $$
|
CREATE FUNCTION search_entities(search text) RETURNS SETOF entities AS $$
|
||||||
SELECT * FROM entities
|
SELECT * FROM entities
|
||||||
WHERE
|
WHERE
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -1416,6 +1416,7 @@ const aliases = [
|
||||||
{
|
{
|
||||||
name: 'dp',
|
name: 'dp',
|
||||||
for: 'dp',
|
for: 'dp',
|
||||||
|
secondary: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'double dildo deepthroat',
|
name: 'double dildo deepthroat',
|
||||||
|
|
|
@ -218,7 +218,7 @@ async function updateReleasesSearch(releaseIds) {
|
||||||
SELECT
|
SELECT
|
||||||
releases.id AS release_id,
|
releases.id AS release_id,
|
||||||
TO_TSVECTOR(
|
TO_TSVECTOR(
|
||||||
'traxxx',
|
'english',
|
||||||
COALESCE(releases.title, '') || ' ' ||
|
COALESCE(releases.title, '') || ' ' ||
|
||||||
entities.name || ' ' ||
|
entities.name || ' ' ||
|
||||||
entities.slug || ' ' ||
|
entities.slug || ' ' ||
|
||||||
|
@ -238,7 +238,7 @@ async function updateReleasesSearch(releaseIds) {
|
||||||
LEFT JOIN releases_actors AS local_actors ON local_actors.release_id = releases.id
|
LEFT JOIN releases_actors AS local_actors ON local_actors.release_id = releases.id
|
||||||
LEFT JOIN releases_tags AS local_tags ON local_tags.release_id = releases.id
|
LEFT JOIN releases_tags AS local_tags ON local_tags.release_id = releases.id
|
||||||
LEFT JOIN actors ON local_actors.actor_id = actors.id
|
LEFT JOIN actors ON local_actors.actor_id = actors.id
|
||||||
LEFT JOIN tags ON local_tags.tag_id = tags.id AND tags.priority >= 7
|
LEFT JOIN tags ON local_tags.tag_id = tags.id AND tags.priority >= 6
|
||||||
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
|
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
|
||||||
${releaseIds ? 'WHERE releases.id = ANY(?)' : ''}
|
${releaseIds ? 'WHERE releases.id = ANY(?)' : ''}
|
||||||
GROUP BY releases.id, entities.name, entities.slug, entities.alias, parents.name, parents.slug, parents.alias;
|
GROUP BY releases.id, entities.name, entities.slug, entities.alias, parents.name, parents.slug, parents.alias;
|
||||||
|
|
Loading…
Reference in New Issue