diff --git a/src/scenes.js b/src/scenes.js index a483f81..0a28feb 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -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 .find((result) => result.columns[0][field] && result.columns[1][count]) ?.data.map((row) => ({ key: row[field], doc_count: row[count] })) @@ -477,6 +478,7 @@ async function queryManticoreSql(filters, options, _reqUser) { } 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) }); } @@ -577,16 +579,16 @@ async function queryManticoreSql(filters, options, _reqUser) { .offset((options.page - 1) * options.limit), // 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, - 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 - 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 - ? 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, */ - channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_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(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(*) desc limit ?', [aggSize]) : null, maxMatches: config.database.manticore.maxMatches, maxQueryTime: config.database.manticore.maxQueryTime, }).toString(); @@ -609,7 +611,8 @@ async function queryManticoreSql(filters, options, _reqUser) { const years = curateFacet(results, 'years_facet', 'count(*)'); const actorIds = curateFacet(results, 'actors_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 studioIds = curateFacet(results, 'studios_facet'); diff --git a/static b/static index cc66e52..258250e 160000 --- a/static +++ b/static @@ -1 +1 @@ -Subproject commit cc66e52e24735014c502ff5bccb3c173c7e69cb8 +Subproject commit 258250e8c01a14cac5525d74b12b7b3563141a82