import ( "github.com/blevesearch/bleve/index/store" "github.com/blevesearch/bleve/index/store/kvstore" "github.com/blevesearch/bleve/index/store/kvstore/boltdb" ) // open BoltDB KV store kvconfig := map[string]interface{}{ "path": "/path/to/kvstore", } kvstore, err := boltdb.Open(kvconfig) defer kvstore.Close() // open KVReader kvReader, err := kvstore.Reader() defer kvReader.Close() // read a document with key "document1" value, err := kvReader.Get([]byte("document1")) if err != nil { // handle error } // value contains the document data
import ( "github.com/blevesearch/bleve/index/store" "github.com/blevesearch/bleve/index/store/kvstore" "github.com/blevesearch/bleve/index/store/kvstore/boltdb" ) // open BoltDB KV store kvconfig := map[string]interface{}{ "path": "/path/to/kvstore", } kvstore, err := boltdb.Open(kvconfig) defer kvstore.Close() // open KVReader kvReader, err := kvstore.Reader() defer kvReader.Close() // iterate through all key-value pairs in KVReader iter := kvReader.Iterator([]byte(nil), []byte(nil)) defer iter.Close() for iter.Seek([]byte(nil)); iter.Valid(); iter.Next() { key := iter.Key() value := iter.Value() // do something with key and value }In both examples, the KVReader package library is used to access the data stored in the key-value store.