Patched manticore death queries.

This commit is contained in:
2026-03-22 02:09:20 +01:00
parent aa68748817
commit 058161f798
2 changed files with 11 additions and 8 deletions

View File

@@ -405,7 +405,8 @@ function curateOptions(options) {
}; };
} }
function curateFacet(results, field, count = 'count(distinct id)') { // function curateFacet(results, field, count = 'count(distinct id)') {
function curateFacet(results, field, count = 'count(*)') {
return results return results
.find((result) => result.columns[0][field] && result.columns[1][count]) .find((result) => result.columns[0][field] && result.columns[1][count])
?.data.map((row) => ({ key: row[field], doc_count: row[count] })) ?.data.map((row) => ({ key: row[field], doc_count: row[count] }))
@@ -477,6 +478,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
} }
if (filters.query) { if (filters.query) {
// we exclude title because we have a curated title_filtered field for more effective results
builder.whereRaw('match(\'@!title :query:\', scenes)', { query: escape(filters.query) }); builder.whereRaw('match(\'@!title :query:\', scenes)', { query: escape(filters.query) });
} }
@@ -577,16 +579,16 @@ async function queryManticoreSql(filters, options, _reqUser) {
.offset((options.page - 1) * options.limit), .offset((options.page - 1) * options.limit),
// option threads=1 fixes actors, but drastically slows down performance, wait for fix // option threads=1 fixes actors, but drastically slows down performance, wait for fix
yearsFacet: options.aggregateYears ? knex.raw('facet effective_year as years_facet order by effective_year desc limit ?', [aggSize]) : null, yearsFacet: options.aggregateYears ? knex.raw('facet effective_year as years_facet order by effective_year desc limit ?', [aggSize]) : null,
actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids as actors_facet distinct id order by count(distinct id) desc limit ?', [aggSize]) : null, actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids as actors_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
// don't facet tags associated to other actors, actor ID 0 means global // don't facet tags associated to other actors, actor ID 0 means global
tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids as tags_facet order by count(distinct id) desc limit ?', [aggSize]) : null, tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids as tags_facet order by count(*) desc limit ?', [aggSize]) : null,
/* /*
actorTagsFacet: options.aggregateTags && !filters.stashId // eslint-disable-line no-nested-ternary actorTagsFacet: options.aggregateTags && !filters.stashId // eslint-disable-line no-nested-ternary
? knex.raw(`facet IF(IN(scenes_tags.actor_id, ${[0, ...filters?.actorIds || []]}), scenes_tags.tag_id, 0) as actor_tags_facet distinct id order by count(distinct id) desc limit ?`, [aggSize]) ? knex.raw(`facet IF(IN(scenes_tags.actor_id, ${[0, ...filters?.actorIds || []]}), scenes_tags.tag_id, 0) as actor_tags_facet distinct id order by count(*) desc limit ?`, [aggSize])
: null, : null,
*/ */
channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_facet distinct id order by count(distinct id) desc limit ?', [aggSize]) : null, channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id as studios_facet distinct id order by count(distinct id) desc limit ?', [aggSize]) : null, studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id as studios_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
maxMatches: config.database.manticore.maxMatches, maxMatches: config.database.manticore.maxMatches,
maxQueryTime: config.database.manticore.maxQueryTime, maxQueryTime: config.database.manticore.maxQueryTime,
}).toString(); }).toString();
@@ -609,7 +611,8 @@ async function queryManticoreSql(filters, options, _reqUser) {
const years = curateFacet(results, 'years_facet', 'count(*)'); const years = curateFacet(results, 'years_facet', 'count(*)');
const actorIds = curateFacet(results, 'actors_facet'); const actorIds = curateFacet(results, 'actors_facet');
const tagIds = curateFacet(results, 'tags_facet'); const tagIds = curateFacet(results, 'tags_facet');
const actorTagIds = curateFacet(results, 'actor_tags_facet'); // const actorTagIds = curateFacet(results, 'actor_tags_facet');
const actorTagIds = [];
const channelIds = curateFacet(results, 'channels_facet'); const channelIds = curateFacet(results, 'channels_facet');
const studioIds = curateFacet(results, 'studios_facet'); const studioIds = curateFacet(results, 'studios_facet');

2
static

Submodule static updated: cc66e52e24...258250e8c0