Picture a typical task: you're writing a Go microservice or CLI tool for a product catalog, a corporate knowledge base, or local documentation. The project has a couple dozen thousand documents, and users need fast, high-quality search with Russian morphology, typo tolerance, and facets.
How does the average team solve this? They drag a separate Elasticsearch or OpenSearch cluster into the architecture, or spin up a Meilisearch container alongside it. Along with the solution comes the classic bundle of infrastructure headaches: a memory-hungry JVM runtime, a couple gigabytes of RAM burned at idle, network roundtrips on every search query, and yet another distributed system to monitor.
But what if you could compile a full-featured, production-grade search engine straight into your single binary—with zero CGo dependencies and no external daemons?
That's exactly what Bleve does, actively developed under the Couchbase umbrella. Full project documentation is available at blevesearch.com. In the current stable v2.5.7 branch, the library delivers the modern Scorch segment storage engine and rich text analyzers.
Spinning Up In-Memory or On-Disk Search in 30 Lines
Bleve's biggest strength is its clean, idiomatic Go architecture. You can feed any arbitrary Go struct or raw JSON slice directly to the indexer.
# Add the modern Bleve v2 release to your project
go get github.com/blevesearch/bleve/v2
Here's what initializing an index with the built-in Russian stemmer looks like:
package main
import (
"fmt"
"log"
"github.com/blevesearch/bleve/v2"
"github.com/blevesearch/bleve/v2/analysis/lang/ru"
"github.com/blevesearch/bleve/v2/mapping"
)
type KnowledgeArticle struct {
ID string `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
}
func buildCustomMapping() mapping.IndexMapping {
indexMapping := bleve.NewIndexMapping()
// Configure document mapping with Russian morphology support
docMapping := bleve.NewDocumentMapping()
contentField := bleve.NewTextFieldMapping()
contentField.Analyzer = ru.PluginName // Snowball stemmer for Russian
docMapping.AddFieldMappingsAt("content", contentField)
indexMapping.AddDocumentMapping("article", docMapping)
return indexMapping
}
func main() {
// Index can live in memory (NewMemOnly) or on disk via BoltDB/Badger
index, err := bleve.NewMemOnly(buildCustomMapping())
if err != nil {
log.Fatalf("Failed to create index: %v", err)
}
defer index.Close()
// Index a document
doc := KnowledgeArticle{
ID: "kb-101",
Title: "Параллелизм в Go",
Content: "Конкурентные горутины обмениваются сообщениями через типизированные каналы.",
}
if err := index.Index(doc.ID, doc); err != nil {
log.Fatalf("Failed to index document: %v", err)
}
// Search by base word form: the stemmer matches «горутины» and «горутина»
query := bleve.NewMatchQuery("горутина")
searchRequest := bleve.NewSearchRequest(query)
searchResult, err := index.Search(searchRequest)
if err != nil {
log.Fatalf("Search failed: %v", err)
}
fmt.Printf("Matches found: %d\n", searchResult.Total)
for _, hit := range searchResult.Hits {
fmt.Printf("Document: %s, Score: %.4f\n", hit.ID, hit.Score)
}
}
Vector Search and Operational Trade-offs
Modern Bleve isn't just keyword search. The v2.5 branch introduced native k-NN vector search (Vector Search), letting you build hybrid search pipelines: traditional word stemming paired with neural network embeddings for semantic search.
Still, when choosing Bleve, it's important to weigh its architectural boundaries soberly:
- Single-node engine: Bleve is designed to be embedded inside a single process. If your system needs index sharding across dozens of servers with terabytes of data, a classic clustered search engine remains unavoidable.
- Contention on concurrent writes: although Scorch is optimized for fast segment merging, parallel writes from hundreds of goroutines to a BoltDB-backed disk store will inevitably hit file-descriptor locks. For high-throughput update queues, you should batch documents via
bleve.NewBatch().
For standalone desktop utilities, compact services, and local tools, Bleve removes a massive layer of infrastructure friction—bringing development back to the simplicity of a single self-contained binary.

