mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-20 04:36:09 +08:00

* feat(search): enhanced `meilisearch` search experience - upgrade `meilisearch` dependency - support subdirectory search - optimize searchDocument fields for subdirectory search - specify full index uid instead of index prefix * fix(search): more fixes to `meilisearch` - make use of context where context was not used - remove code of waiting task in deletion process, as tasks are queued and will be executed orderly (if tasks were submitted to the queue successfully), which can improve `AutoUpdate` performance
32 lines
970 B
Go
32 lines
970 B
Go
package meilisearch
|
|
|
|
import (
|
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
|
)
|
|
|
|
// hashPath hashes a path with SHA-1.
|
|
// Path-relative exact matching should use hash,
|
|
// because filtering strings on meilisearch is case-insensitive.
|
|
func hashPath(path string) string {
|
|
return utils.HashData(utils.SHA1, []byte(path))
|
|
}
|
|
|
|
func buildSearchDocumentFromResults(results map[string]any) *searchDocument {
|
|
searchNode := model.SearchNode{}
|
|
document := &searchDocument{
|
|
SearchNode: searchNode,
|
|
}
|
|
|
|
// use assertion test to avoid panic
|
|
searchNode.Parent, _ = results["parent"].(string)
|
|
searchNode.Name, _ = results["name"].(string)
|
|
searchNode.IsDir, _ = results["is_dir"].(bool)
|
|
searchNode.Size, _ = results["size"].(int64)
|
|
|
|
document.ID, _ = results["id"].(string)
|
|
document.ParentHash, _ = results["parent_hash"].(string)
|
|
document.ParentPathHashes, _ = results["parent_path_hashes"].([]string)
|
|
return document
|
|
}
|