local_storage — Bleve-backed local full-text search
import "github.com/downsized-devs/sdk-go/local_storage"
Stability: Stable — see STABILITY.md
Local on-disk search index using Bleve. For embedded search inside a single service — not a clustered solution.
Features
NewIndex(name) — create a new index on disk.
Index(name, id, doc) — add or replace a document.
Search(name, query) — text search returning IDs and scores.
DeleteIndex(name) — drop the index.
Installation
go get github.com/downsized-devs/sdk-go/local_storage
Quick Start
ls := local_storage.Init(local_storage.Config{
Path: "./search-index",
}, log)
_ = ls.NewIndex(ctx, "products")
_ = ls.Index(ctx, "products", "p1", map[string]any{"name": "Apple"})
hits, _ := ls.Search(ctx, "products", "apple")
API Reference
| Symbol |
Signature |
Init |
func Init(cfg Config, log logger.Interface) Interface |
Interface.NewIndex |
(ctx, name string) error |
Interface.Index |
(ctx, name, id string, doc any) error |
Interface.Search |
(ctx, name, query string) (Results, error) |
Interface.DeleteIndex |
(ctx, name string) error |
Configuration
| Field |
Description |
Path |
Filesystem path where indexes live. |
Dependencies
- Internal:
logger
- External:
github.com/blevesearch/bleve
Testing
go test ./local_storage/...
Contributing
See CONTRIBUTING.md. The on-disk index format is owned by Bleve — don't make assumptions about layout.
storage — remote S3-backed object storage.
logger — required at Init time.