forked from DebaucheryLibrarian/traxxx
Removed PG stop word dictionary. Filtering and ordering search results in GraphQL query.
This commit is contained in:
parent
3310236767
commit
bb9fbc77a9
|
@ -7,7 +7,7 @@ Use [nvm](https://github.com/creationix/nvm) to install NodeJS v14.15.4 or newer
|
|||
`npm install`
|
||||
|
||||
### Set up database
|
||||
Install PostgreSQL, make sure password authentication is enabled (scram-sha-256) and create a database with a privileged user. For optimal search engine performance, copy `traxxx.stop` to your PostgresQL text search directory, usually `/usr/share/postgresql/tsearch_data/ or `/usr/local/share/postgresql/tsearch_data/`.
|
||||
Install PostgreSQL, make sure password authentication is enabled (scram-sha-256) and create a database with a privileged user.
|
||||
|
||||
### Configuration
|
||||
Do not modify `config/default.js`, but instead create a copy at `config/local.js` containing the properties you wish to change. If you have set `NODE_ENV`, copy `assets/js/config/default.js` to `assets/js/config/[environment].js`. After setting up PostgreSQL and configuring the details, run the following commands to create and populate the tables, and build the project:
|
||||
|
|
|
@ -37,7 +37,12 @@ function initUiActions(_store, _router) {
|
|||
results: searchReleases(
|
||||
query: $query
|
||||
first: $limit
|
||||
minimumRank: "0.025"
|
||||
orderBy: RANK_DESC
|
||||
filter: {
|
||||
rank: {
|
||||
greaterThan: 0.025
|
||||
}
|
||||
}
|
||||
) {
|
||||
release: releaseById {
|
||||
id
|
||||
|
|
|
@ -981,20 +981,8 @@ exports.up = knex => Promise.resolve()
|
|||
.then(() => { // eslint-disable-line arrow-body-style
|
||||
// allow vim fold
|
||||
return knex.raw(`
|
||||
CREATE TEXT SEARCH DICTIONARY traxxx_dict (
|
||||
TEMPLATE = pg_catalog.simple,
|
||||
stopwords = traxxx
|
||||
);
|
||||
|
||||
CREATE TEXT SEARCH CONFIGURATION traxxx (
|
||||
COPY = english
|
||||
);
|
||||
|
||||
ALTER TABLE releases_search
|
||||
ADD COLUMN document tsvector;
|
||||
|
||||
ALTER TEXT SEARCH CONFIGURATION traxxx
|
||||
ALTER MAPPING FOR word, numword, hword, numhword, hword_part, hword_numpart, asciiword, asciihword, hword_asciipart WITH traxxx_dict, simple, english_stem;
|
||||
`);
|
||||
})
|
||||
// INDEXES
|
||||
|
@ -1012,20 +1000,12 @@ exports.up = knex => Promise.resolve()
|
|||
.then(() => { // eslint-disable-line arrow-body-style
|
||||
// allow vim fold
|
||||
return knex.raw(`
|
||||
CREATE FUNCTION search_releases_legacy(query text) RETURNS SETOF releases AS $$
|
||||
SELECT * FROM releases WHERE releases.id IN (
|
||||
SELECT release_id FROM releases_search AS search
|
||||
WHERE search.document @@ plainto_tsquery('traxxx', regexp_replace(query, '\\.|-|(XXX\\.[\\d+|hd|sd].*$)', ' ', 'ig'))
|
||||
ORDER BY ts_rank(search.document, plainto_tsquery('traxxx', regexp_replace(query, '\\.|-|(XXX\\.[\\d+|hd|sd].*$)', ' ', 'ig'))) DESC
|
||||
);
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
|
||||
/* We need both the release entries and their search ranking, and PostGraphile does not seem to allow virtual foreign keys on function results.
|
||||
* Using a view as a proxy for the search results allows us to get both a reference to the releases table, and the ranking */
|
||||
CREATE VIEW releases_search_results AS
|
||||
SELECT NULL::integer as id, NULL::real as rank;
|
||||
|
||||
CREATE FUNCTION search_releases(query text, minimum_rank numeric DEFAULT 0) RETURNS SETOF releases_search_results AS $$
|
||||
CREATE FUNCTION search_releases(query text) RETURNS SETOF releases_search_results AS $$
|
||||
SELECT releases.id, ranks.rank FROM (
|
||||
SELECT
|
||||
releases_search.release_id,
|
||||
|
@ -1033,7 +1013,7 @@ exports.up = knex => Promise.resolve()
|
|||
FROM releases_search
|
||||
) ranks
|
||||
LEFT JOIN releases ON releases.id = ranks.release_id
|
||||
WHERE ranks.rank > minimum_rank
|
||||
WHERE ranks.rank > 0
|
||||
ORDER BY ranks.rank DESC;
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
|
||||
|
@ -1199,8 +1179,8 @@ exports.up = knex => Promise.resolve()
|
|||
COMMENT ON FUNCTION actors_channels IS E'@sortable';
|
||||
COMMENT ON FUNCTION actors_actors IS E'@sortable';
|
||||
COMMENT ON FUNCTION actors_scenes IS E'@sortable';
|
||||
|
||||
COMMENT ON FUNCTION tags_scenes IS E'@sortable';
|
||||
COMMENT ON FUNCTION search_releases IS E'@sortable';
|
||||
|
||||
COMMENT ON VIEW releases_search_results is E'@foreignKey (id) REFERENCES releases (id)';
|
||||
`);
|
||||
|
|
160
traxxx.stop
160
traxxx.stop
|
@ -1,160 +0,0 @@
|
|||
i
|
||||
me
|
||||
my
|
||||
myself
|
||||
we
|
||||
our
|
||||
ours
|
||||
ourselves
|
||||
you
|
||||
your
|
||||
yours
|
||||
yourself
|
||||
yourselves
|
||||
he
|
||||
him
|
||||
his
|
||||
himself
|
||||
she
|
||||
her
|
||||
hers
|
||||
herself
|
||||
it
|
||||
its
|
||||
itself
|
||||
they
|
||||
them
|
||||
their
|
||||
theirs
|
||||
themselves
|
||||
what
|
||||
which
|
||||
who
|
||||
whom
|
||||
this
|
||||
that
|
||||
these
|
||||
those
|
||||
am
|
||||
is
|
||||
are
|
||||
was
|
||||
were
|
||||
be
|
||||
been
|
||||
being
|
||||
have
|
||||
has
|
||||
had
|
||||
having
|
||||
do
|
||||
does
|
||||
did
|
||||
doing
|
||||
a
|
||||
an
|
||||
the
|
||||
and
|
||||
but
|
||||
if
|
||||
or
|
||||
because
|
||||
as
|
||||
until
|
||||
while
|
||||
of
|
||||
at
|
||||
by
|
||||
for
|
||||
with
|
||||
about
|
||||
against
|
||||
between
|
||||
into
|
||||
through
|
||||
during
|
||||
before
|
||||
after
|
||||
above
|
||||
below
|
||||
to
|
||||
from
|
||||
up
|
||||
down
|
||||
in
|
||||
out
|
||||
on
|
||||
off
|
||||
over
|
||||
under
|
||||
again
|
||||
further
|
||||
then
|
||||
once
|
||||
here
|
||||
there
|
||||
when
|
||||
where
|
||||
why
|
||||
how
|
||||
all
|
||||
any
|
||||
both
|
||||
each
|
||||
few
|
||||
more
|
||||
most
|
||||
other
|
||||
some
|
||||
such
|
||||
no
|
||||
nor
|
||||
not
|
||||
only
|
||||
own
|
||||
same
|
||||
so
|
||||
than
|
||||
too
|
||||
very
|
||||
s
|
||||
t
|
||||
can
|
||||
will
|
||||
just
|
||||
don
|
||||
should
|
||||
now
|
||||
1080p
|
||||
2160p
|
||||
240p
|
||||
360p
|
||||
480p
|
||||
540p
|
||||
720p
|
||||
avi
|
||||
com
|
||||
gagvid
|
||||
h264
|
||||
hd
|
||||
kleenex
|
||||
ktr
|
||||
mkv
|
||||
mov
|
||||
mp4
|
||||
net
|
||||
rarbg
|
||||
rartv
|
||||
robots
|
||||
scenes
|
||||
sd
|
||||
split
|
||||
tbs
|
||||
trashbin
|
||||
tv
|
||||
web
|
||||
webrip
|
||||
wmv
|
||||
x264
|
||||
xlf
|
||||
xxx
|
Loading…
Reference in New Issue