bleve

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package bleve implements the search.Engine interface using Bleve as an in-process full-text search engine. It supports both disk-backed and in-memory indexes.

Basic usage:

eng, err := bleve.NewDefault("/tmp/myindex")
if err != nil { log.Fatal(err) }
defer eng.Close()

eng.Index(ctx, search.Doc{
    ID:   "doc1",
    Type: "article",
    Fields: map[string]any{
        "title":   "Hello World",
        "content": "This is a test document",
    },
})

res, _ := eng.Search(ctx, search.NewKeywordSearch("hello", 10))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIndexMapping

func BuildIndexMapping(defaultAnalyzer string) *mapping.IndexMappingImpl

BuildIndexMapping creates a default Bleve index mapping with common field mappings for text, keyword, numeric, and datetime fields.

func New

New creates a new Engine backed by a Bleve index at cfg.IndexPath. If the path doesn't exist a new index is created; if it exists the index is opened.

func NewDefault

func NewDefault(indexPath string) (search.Engine, error)

NewDefault creates a new Engine with a default configuration and mapping. The index is stored on disk at indexPath.

func NewMemory

func NewMemory() (search.Engine, error)

NewMemory creates a new Engine backed by an in-memory index (no disk persistence). This is useful for testing and ephemeral search scenarios.

Types

type Config

type Config struct {
	// IndexPath is the filesystem path for the Bleve index.
	// Leave empty for in-memory indexes (use NewMemory).
	IndexPath string

	// DefaultAnalyzer is the Bleve analyzer name (e.g. "standard", "keyword").
	// Empty defaults to "standard".
	DefaultAnalyzer string

	// DefaultSearchFields are the fields searched when SearchRequest.SearchFields
	// is not specified.
	DefaultSearchFields []string

	// QueryTimeout is the max duration for individual index/search operations.
	// 0 means no timeout.
	QueryTimeout time.Duration

	// BatchSize is the number of documents per batch in IndexBatch.
	// 0 defaults to 100.
	BatchSize int
}

Config holds Bleve search engine configuration.

func DefaultConfig

func DefaultConfig(indexPath string) Config

DefaultConfig returns a Config with sensible defaults.

Jump to

Keyboard shortcuts

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