blevesearch / blevex

Bleve Extensions
47 stars 23 forks source link

How to use this ? #19

Closed thomasmodeneis closed 8 years ago

thomasmodeneis commented 8 years ago

HI,

I know this maybe obvious for you, but I'm struggling a bit to manage to make sense of this project, by that I mean how to I use it ?

I would like to test the leveldb extension, but I'm not sure how to start with.

would you mind giving a quick heads up here with steps to use it ?

Thanks

mschoch commented 8 years ago

Sure,

So, let's assume you already have a working bleve program, but it uses the default KV store which is boltdb. To use leveldb (the C version) you would do the following:

  1. Install the leveldb C library on your system, and either install into the system paths, or set CGO_CFLAGS and CGO_LDFLAGS so that it can be found.
  2. Do a 'go get github.com/blevex/leveldb'
  3. Run the unit tests in this package (cd into the directory and run 'go test -v' This should confirm that the library has been found is working as expected.
  4. Finally, going back to your original program, make the following changes:

Add import for "github.com/blevex/leveldb"

Change line saying:

index, err := bleve.New(path, mapping)

to

index, err := bleve.NewUsing(path, mapping, bleve.Config.DefaultIndexType, leveldb.Name, nil)

If your code later opens existing indexes, it can use the standard Open() call and it should detect "leveldb" automatically, but, you still need to always include the "leveldb" package above to ensure that functionality is linked into the application.

Let me know if any of this isn't clear.

thomasmodeneis commented 8 years ago

Hi @mschoch

Thanks for your great help, I will be working on this during the weekend and will get back to you here in case I find any complications during the implementation :)

Thank you again, Thomas.