From 330d2f3a316be553caa8a6de145b4ec3f357bef4 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 29 Jul 2026 17:39:23 +0200 Subject: [PATCH] refactor(search): run the bleve backend on the shared lowering pass The bleve Creator runs query.Normalize before compiling; the compiler consumes a canonical AST with no field resolution or media-type special-casing. --- services/search/pkg/query/bleve/bleve.go | 4 + services/search/pkg/query/bleve/compiler.go | 129 ++---------------- .../search/pkg/query/bleve/compiler_test.go | 8 +- 3 files changed, 19 insertions(+), 122 deletions(-) diff --git a/services/search/pkg/query/bleve/bleve.go b/services/search/pkg/query/bleve/bleve.go index 0acbc80095..41e260b81c 100644 --- a/services/search/pkg/query/bleve/bleve.go +++ b/services/search/pkg/query/bleve/bleve.go @@ -22,6 +22,10 @@ func (c Creator[T]) Create(qs string) (T, error) { return t, err } + // shared KQL lowering pass: resolve field names + expand media-type aliases + // once, so the compiler below sees only canonical field:value nodes. + builderAst = query.Normalize(builderAst, query.ResolveField) + t, err = c.compiler.Compile(builderAst) if err != nil { return t, err diff --git a/services/search/pkg/query/bleve/compiler.go b/services/search/pkg/query/bleve/compiler.go index 02f5c17992..944065b46d 100644 --- a/services/search/pkg/query/bleve/compiler.go +++ b/services/search/pkg/query/bleve/compiler.go @@ -16,22 +16,6 @@ import ( // backend via search.LowercaseValueFields; every other field keeps its casing. var lowercaseFields = search.LowercaseValueFields() -var _fields = map[string]string{ - "rootid": "RootID", - "path": "Path", - "id": "ID", - "name": "Name", - "size": "Size", - "mtime": "Mtime", - "mediatype": "MimeType", - "type": "Type", - "tag": "Tags", - "tags": "Tags", - "content": "Content", - "hidden": "Hidden", - "favorite": "Favorites", -} - // The following quoted string enumerates the characters which may be escaped: "+-=&|>