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 ¶
NewDefault creates a new Engine with a default configuration and mapping. The index is stored on disk at indexPath.
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 ¶
DefaultConfig returns a Config with sensible defaults.