MCPcopy Index your code
hub / github.com/blugelabs/bluge

github.com/blugelabs/bluge @v0.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.2 ↗ · + Follow
2,219 symbols 8,643 edges 406 files 235 documented · 11% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Bluge Bluge

PkgGoDev Tests Lint

modern text indexing in go - blugelabs.com

Features

  • Supported field types:
    • Text, Numeric, Date, Geo Point
  • Supported query types:
    • Term, Phrase, Match, Match Phrase, Prefix
    • Conjunction, Disjunction, Boolean
    • Numeric Range, Date Range
  • BM25 Similarity/Scoring with pluggable interfaces
  • Search result match highlighting
  • Extendable Aggregations:
    • Bucketing
      • Terms
      • Numeric Range
      • Date Range
    • Metrics
      • Min/Max/Count/Sum
      • Avg/Weighted Avg
      • Cardinality Estimation (HyperLogLog++)
      • Quantile Approximation (T-Digest)

Indexing

    config := bluge.DefaultConfig(path)
    writer, err := bluge.OpenWriter(config)
    if err != nil {
        log.Fatalf("error opening writer: %v", err)
    }
    defer writer.Close()

    doc := bluge.NewDocument("example").
        AddField(bluge.NewTextField("name", "bluge"))

    err = writer.Update(doc.ID(), doc)
    if err != nil {
        log.Fatalf("error updating document: %v", err)
    }

Querying

    reader, err := writer.Reader()
    if err != nil {
        log.Fatalf("error getting index reader: %v", err)
    }
    defer reader.Close()

    query := bluge.NewMatchQuery("bluge").SetField("name")
    request := bluge.NewTopNSearch(10, query).
        WithStandardAggregations()
    documentMatchIterator, err := reader.Search(context.Background(), request)
    if err != nil {
        log.Fatalf("error executing search: %v", err)
    }
    match, err := documentMatchIterator.Next()
    for err == nil && match != nil {
        err = match.VisitStoredFields(func(field string, value []byte) bool {
            if field == "_id" {
                fmt.Printf("match: %s\n", string(value))
            }
            return true
        })
        if err != nil {
            log.Fatalf("error loading stored fields: %v", err)
        }
        match, err = documentMatchIterator.Next()
    }
    if err != nil {
        log.Fatalf("error iterator document matches: %v", err)
    }

Repobeats

Alt

License

Apache License Version 2.0

Extension points exported contracts — how you extend this code

Query (Interface)
A Query represents a description of the type and parameters for a query into the index. [19 implementers]
query.go
FieldConsumer (Interface)
FieldConsumer is anything which can consume a field Fields can implement this interface to consume the content of anothe [10 …
document.go
TokenFilter (Interface)
A TokenFilter adds, transforms or removes tokens from a token stream. [50 implementers]
analysis/type.go
TextValueSource (Interface)
(no doc) [6 implementers]
search/source.go
Searcher (Interface)
(no doc) [9 implementers]
search/search.go
Aggregation (Interface)
(no doc) [8 implementers]
search/aggregations.go
Collectible (Interface)
(no doc) [11 implementers]
search/collector.go
State (Interface)
States codify the classes that the parser recognizes. [4 implementers]
analysis/token/camelcase_states.go

Core symbols most depended-on inside this repo

AddField
called by 299
document.go
Fatalf
called by 208
index_test.go
Next
called by 143
search/search.go
Close
called by 141
search/search.go
NewTextField
called by 129
field.go
NewTopNSearch
called by 127
search.go
flag
called by 110
analysis/lang/in/scripts.go
Close
called by 107
index/lock/lock.go

Shape

Method 1,054
Function 824
Struct 239
Interface 50
TypeAlias 40
FuncType 12

Languages

Go100%

Modules by API surface

query.go187 symbols
search/source.go81 symbols
search/searcher/stub_test.go61 symbols
search/search.go59 symbols
field.go59 symbols
index/snapshot.go38 symbols
search.go37 symbols
index_test.go37 symbols
index/unadorned.go30 symbols
search/aggregations.go28 symbols
index/docstub_test.go28 symbols
search/searcher/docstub_test.go27 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add bluge \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact