[search] Legacy search fallback support legacy query params (#99765)

* add support for deleted query param

* support tag query param in modes 2 and below

* handle dashboardIds

* hhandle dashboardUIDs

* handle folderUIDs query param

* handle page query param when hitting legacy storage

* handle sort query param

* handle type query param

* re-enable search fallback

* remove folder search workaround and fix /api/search to return both folders and dashboards when no title or type is provided

---------

Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
Will Assis
2025-02-06 11:30:47 -05:00
committed by GitHub
co-authored by Stephanie Hingtgen
parent ccb0e9222a
commit 1467d4b3e3
13 changed files with 646 additions and 444 deletions
+33
View File
@@ -10,6 +10,8 @@ import (
"sync"
"time"
dashboardv0alpha1 "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1"
folderv0alpha1 "github.com/grafana/grafana/pkg/apis/folder/v0alpha1"
"github.com/hashicorp/golang-lru/v2/expirable"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
@@ -651,3 +653,34 @@ func (s *builderCache) get(ctx context.Context, key NamespacedResource) (Documen
}
return s.defaultBuilder, nil
}
// AsResourceKey converts the given namespace and type to a search key
func AsResourceKey(ns string, t string) (*ResourceKey, error) {
if ns == "" {
return nil, fmt.Errorf("missing namespace")
}
switch t {
case "folders", "folder":
return &ResourceKey{
Namespace: ns,
Group: folderv0alpha1.GROUP,
Resource: folderv0alpha1.RESOURCE,
}, nil
case "dashboards", "dashboard":
return &ResourceKey{
Namespace: ns,
Group: dashboardv0alpha1.GROUP,
Resource: dashboardv0alpha1.RESOURCE,
}, nil
// NOT really supported in the dashboard search UI, but useful for manual testing
case "playlist", "playlists":
return &ResourceKey{
Namespace: ns,
Group: "playlist.grafana.app",
Resource: "playlists",
}, nil
}
return nil, fmt.Errorf("unknown resource type")
}