From 0249f97d2211e3cf42948340ceab4a98a658f2e4 Mon Sep 17 00:00:00 2001 From: Fredd C Date: Thu, 16 Jul 2026 15:30:38 +0800 Subject: [PATCH] fix: match files to scenes whose titles contain apostrophes --- pkg/api/scenes.go | 7 ++++++- ui/src/views/files/SceneMatch.vue | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/api/scenes.go b/pkg/api/scenes.go index ef736bd30..70cf0f503 100644 --- a/pkg/api/scenes.go +++ b/pkg/api/scenes.go @@ -673,7 +673,12 @@ func (i SceneResource) searchSceneIndex(req *restful.Request, resp *restful.Resp } defer idx.Bleve.Close() - query := bleve.NewQueryStringQuery(q) + // The index analyzer splits on apostrophes ("Sister's" -> "sister", "s"), so a query + // keeping the apostrophe ("Sister's") or dropping it ("Sisters") never lines up with + // the indexed terms. Normalising apostrophes to spaces ("Sister s") matches how titles + // are tokenised, which is what filename-derived match queries need. + bleveQuery := strings.NewReplacer("'", " ", "’", " ", "`", " ").Replace(q) + query := bleve.NewQueryStringQuery(bleveQuery) searchRequest := bleve.NewSearchRequest(query) searchRequest.Fields = []string{"Id", "title", "cast", "site", "description"} diff --git a/ui/src/views/files/SceneMatch.vue b/ui/src/views/files/SceneMatch.vue index 26139118e..5d8bf9534 100644 --- a/ui/src/views/files/SceneMatch.vue +++ b/ui/src/views/files/SceneMatch.vue @@ -151,9 +151,8 @@ export default { this.data = [] this.queryString = ( this.file.filename - .replace(/\.|_|\+|-/g, ' ').replace(/\s+/g, ' ').trim() - .split(' ').filter(isNotCommonWord).join(' ') - .replace(/ s /g, '\'s ')) + .replace(/[._+'’`-]/g, ' ').replace(/\s+/g, ' ').trim() + .split(' ').filter(isNotCommonWord).join(' ')) this.loadData() }, loadData: async function loadData () {