Getting started with Bleve using BoltDB

332 views
Skip to first unread message

Lisa

unread,
Feb 9, 2016, 11:31:53 PM2/9/16
to bleve
Hi.

I have been trying to use Bleve for the past 2 weeks but I can't seem to wrap my head around it when it comes to using BoltDB. Can someone guide me on how this can be done? I also posted a question on the same: http://stackoverflow.com/questions/34973055/getting-started-with-bleve-using-boltdb/34979182#34979182

Any help will be hghly appreciated.

Marty Schoch

unread,
Feb 9, 2016, 11:38:11 PM2/9/16
to bl...@googlegroups.com
Hello,

I saw your question on StackOverflow, but I didn't respond because I thought the answer from Ben Johnson was correct and clear.  I upvoted it, but it seems others have upvoted the other answer, which I though missed the mark as it ignored your desire to use Bleve.  I think there are 2 main points I can clarify, and then beyond that we'll need more information about what you've already tried.

1.  Bleve uses BoltDB by default for it's own index storage.  For most users this is an implementation detail they can ignore, so I'm assuming this is not what you mean by "using Bleve with BotlDB".

2.  There is no out of the box integration for using Bleve with any other database.  It is a library, so if you want to index data, you have to pass your data to the Index() method as described in Ben Johnson's answer on StackOverflow.

I'm happy to try and help further, but I think we need more information about what exactly you're trying to do, and what you've already tried.

Thanks,
marty

--
You received this message because you are subscribed to the Google Groups "bleve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bleve+un...@googlegroups.com.
To post to this group, send email to bl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bleve/f017262b-9659-40a4-b3a8-150d9dc5be5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lisa

unread,
Feb 10, 2016, 12:34:52 AM2/10/16
to bleve
Thank you so much for the response


On Wednesday, 10 February 2016 07:38:11 UTC+3, Marty Schoch wrote:
Hello,

I saw your question on StackOverflow, but I didn't respond because I thought the answer from Ben Johnson was correct and clear.  I upvoted it, but it seems others have upvoted the other answer, which I though missed the mark as it ignored your desire to use Bleve.  I think there are 2 main points I can clarify, and then beyond that we'll need more information about what you've already tried.

1.  Bleve uses BoltDB by default for it's own index storage.  For most users this is an implementation detail they can ignore, so I'm assuming this is not what you mean by "using Bleve with BotlDB".

this is where I get confused. BoltDB is a default for bleve but how? There is no documentation in Bleve that uses BoltDB. I have come across this import: github.com/blevesearch/bleve/index/store/boltdb but my poor programming skills don't allow me to understand how to use it or if its even necessary for the process

2.  There is no out of the box integration for using Bleve with any other database.  It is a library, so if you want to index data, you have to pass your data to the Index() method as described in Ben Johnson's answer on StackOverflow.

I'm happy to try and help further, but I think we need more information about what exactly you're trying to do, and what you've already tried.

What I have done so far is iterate through what I have in BoltDB (data.db)  and then indexed it and saved it as data.bleve. After that, I tried doing a mapping and querying it. It seems to work OK (some result is returned though not in the format I expected. I think my mapping is all wrong or maybe my solution is wrong).

I am not sure if this is the right way to do it as I did not use github.com/blevesearch/bleve/index/store/boltdb at any point.

Thanks,
marty



Regards.

Marty Schoch

unread,
Feb 10, 2016, 11:08:23 AM2/10/16
to bl...@googlegroups.com
On Wed, Feb 10, 2016 at 12:34 AM, Lisa <lista...@gmail.com> wrote:

this is where I get confused. BoltDB is a default for bleve but how? There is no documentation in Bleve that uses BoltDB. I have come across this import: github.com/blevesearch/bleve/index/store/boltdb but my poor programming skills don't allow me to understand how to use it or if its even necessary for the process

There is nothing you need to do.  The documentation does not go into it because users don't have to do anything.  Advanced users may opt to choose something other than BoltDB, that is why we have a layer of abstraction in place.  I can explain in more detail how we use BoltDB internally, but I think this is likely to just lead to more confusion right now.
 

2.  There is no out of the box integration for using Bleve with any other database.  It is a library, so if you want to index data, you have to pass your data to the Index() method as described in Ben Johnson's answer on StackOverflow.

I'm happy to try and help further, but I think we need more information about what exactly you're trying to do, and what you've already tried.

What I have done so far is iterate through what I have in BoltDB (data.db)  and then indexed it and saved it as data.bleve. After that, I tried doing a mapping and querying it. It seems to work OK (some result is returned though not in the format I expected. I think my mapping is all wrong or maybe my solution is wrong).

I am not sure if this is the right way to do it as I did not use github.com/blevesearch/bleve/index/store/boltdb at any point. 

For simple use cases, especially when you're first getting started, you do not need to use any package other than the top-level bleve package.

That said, some of the steps you said you tried above are out of order.  The first thing you must do is build the mapping.  The mapping tells bleve how to index the data you give to it.  In many cases (but not all) you can use the default mapping, as returned by NewIndexMapping().  To help you determine if the default mapping will work, please share with the group a copy of the data structure you are trying to index.

Next, once you have an appropriate mapping, you have to pass it as the second argument when calling New().  The first argument is path to the index you're creating.

Finally, once the index is open, you will make calls to Index() and pass in data to be indexed.

I would recommend you start with a simple example where you can share the source code with the group.  It's much easier to work with a concrete example program.

marty
Reply all
Reply to author
Forward
0 new messages