Skip to content
/ bdodb Public

bdodb is a badger based backend database for bleve

License

Notifications You must be signed in to change notification settings

mkawserm/bdodb

Repository files navigation

bdodb

GoDoc Build Status Go Report Card Coverage Status


Package bdodb is a badger based backend database for bleve with all the customization options provided by the badger

Usage

➜ go get github.com/mkawserm/bdodb

package main

import (
    "fmt"
    "github.com/blevesearch/bleve"
    "github.com/blevesearch/bleve/index/upsidedown"
    "github.com/mkawserm/bdodb"
)

func main() { 
    // create or open bleveIndex
    index, err := bdodb.BleveIndex("/tmp/bdodb", bleve.NewIndexMapping(), upsidedown.Name, nil)
    
    message := struct{
        Id   string
        Body string
    }{
        Id:   "custom_id", 
        Body: "bleve indexing with badger using bdodb",
    }
    
    // index message data 
    err = index.Index(message.Id, message)
    if err !=nil {
        panic(err)
    }
    
    // search for some text 
    query := bleve.NewQueryStringQuery("bdodb")
    search := bleve.NewSearchRequest(query)
    if searchResults, err := index.Search(search); err == nil {
        fmt.Println(searchResults)
    } else {
        fmt.Println(err)
    }
}