local_storage

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 6 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IndexPath string
}

type Interface

type Interface interface {
	Index(ctx context.Context, key string, data interface{}) error
	Search(ctx context.Context, query string) ([]string, error)
	DeleteIndex(ctx context.Context, indexDir string) error
	NewIndex(ctx context.Context, indexPath string) error
}

func Init

func Init(cfg Config, log logger.Interface) Interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL