Serializing aliased actors as searchable text field in manticore.
This commit is contained in:
@@ -369,11 +369,13 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
builder.select(knex.raw('*, weight() as _score'));
|
||||
}
|
||||
|
||||
builder.where('alias_for', 0);
|
||||
|
||||
if (filters.query) {
|
||||
if (filters.query.charAt(0) === '#') {
|
||||
builder.where('id', Number(escape(filters.query.slice(1))));
|
||||
} else {
|
||||
builder.whereRaw('match(\'@name :query:\', actors)', { query: escape(filters.query) });
|
||||
builder.whereRaw('match(\'@(name,aliases) :query:\', actors)', { query: escape(filters.query) });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
src/sync.js
11
src/sync.js
@@ -382,11 +382,14 @@ export async function syncManticoreActors(actorIds) {
|
||||
const actors = await knex.raw(`
|
||||
SELECT
|
||||
actors.*,
|
||||
actors_meta.*,
|
||||
date_of_birth AT TIME ZONE 'Europe/Amsterdam' AT TIME ZONE 'UTC' as dob
|
||||
actors_meta.stashed, actors_meta.scenes,
|
||||
STRING_AGG(DISTINCT aliases.name, ',') FILTER (WHERE LOWER(aliases.name) != LOWER(actors.name)) as alias,
|
||||
actors.date_of_birth AT TIME ZONE 'Europe/Amsterdam' AT TIME ZONE 'UTC' as dob
|
||||
FROM actors
|
||||
LEFT JOIN actors_meta ON actors_meta.actor_id = actors.id
|
||||
LEFT JOIN actors AS aliases ON aliases.alias_for = actors.id
|
||||
${actorIds ? 'WHERE actors.id = ANY(?)' : ''}
|
||||
GROUP BY actors.id, actors_meta.stashed, actors_meta.scenes
|
||||
`, actorIds && [actorIds]);
|
||||
|
||||
const actorsById = Object.fromEntries(actors.rows.map((actor) => [actor.id, actor]));
|
||||
@@ -408,7 +411,9 @@ export async function syncManticoreActors(actorIds) {
|
||||
index: 'actors',
|
||||
id: actor.id,
|
||||
doc: {
|
||||
entity_id: actor.entity_id,
|
||||
entity_id: actor.entity_id || undefined,
|
||||
alias_for: actor.alias_for || undefined,
|
||||
aliases: actor.alias,
|
||||
name: actor.name,
|
||||
slug: actor.slug,
|
||||
gender: actor.gender || undefined,
|
||||
|
||||
@@ -10,8 +10,10 @@ async function init() {
|
||||
await utilsApi.sql(`create table actors(
|
||||
id int,
|
||||
name text,
|
||||
aliases text,
|
||||
slug string,
|
||||
entity_id int,
|
||||
alias_for int,
|
||||
gender string,
|
||||
date_of_birth timestamp,
|
||||
country string,
|
||||
|
||||
Reference in New Issue
Block a user