Commit 75933a3d authored by ale's avatar ale

use goleveldb as the Bleve backend

parent bc3555a5
......@@ -20,6 +20,7 @@ import (
_ "git.autistici.org/ale/liber/Godeps/_workspace/src/github.com/blevesearch/bleve/analysis/analyzers/simple_analyzer"
_ "git.autistici.org/ale/liber/Godeps/_workspace/src/github.com/blevesearch/bleve/analysis/analyzers/standard_analyzer"
_ "git.autistici.org/ale/liber/Godeps/_workspace/src/github.com/blevesearch/bleve/analysis/token_filters/edge_ngram_filter"
blevegoleveldb "git.autistici.org/ale/liber/Godeps/_workspace/src/github.com/blevesearch/bleve/index/store/goleveldb"
"git.autistici.org/ale/liber/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb"
ldbfilter "git.autistici.org/ale/liber/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter"
......@@ -210,10 +211,10 @@ func NewDb(path string) (*Database, error) {
}
func (db *Database) setupLevelDb(path string) error {
// Use 256MB of cache and a small Bloom filter.
// Use 128MB of cache and a small Bloom filter.
opts := &ldbopt.Options{
Filter: ldbfilter.NewBloomFilter(10),
BlockCacheCapacity: 2 << 28,
BlockCacheCapacity: 2 << 27,
}
ldb, err := leveldb.OpenFile(path, opts)
......@@ -229,7 +230,13 @@ func (db *Database) setupIndex(path string) error {
if _, serr := os.Stat(path); serr == nil {
db.index, err = bleve.Open(path)
} else {
db.index, err = bleve.New(path, defaultIndexMapping())
// Create a new Bleve index, backed by goleveldb.
db.index, err = bleve.NewUsing(path, defaultIndexMapping(), bleve.Config.DefaultIndexType, blevegoleveldb.Name, map[string]interface{}{
"create_if_missing": true,
"write_buffer_size": 2 << 25,
"lru_cache_capacity": 2 << 27,
"bloom_filter_bits_per_key": 10,
})
}
if err != nil {
return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment