Thomas
Thomas

Reputation: 34218

How to create lucene.net index in database

when we are using winform to index data through lucene.net then think say 10 same win apps is running in a office and they all index data. if the index segment file is created in every pc then it will be problem or we can create in any centralize pc but problem occur when that pc suddenly being unavailable from network. so i like to know can we store lucene.net index in sql server for centralize access. if possible please guide me. i search lot for storing lucene.net index in sql server but found none. i got a article on java and they i saw it is possible. here is the link http://kalanir.blogspot.in/2008/06/creating-search-index-in-database.html

they said Lucence contains the JdbcDirectory interface for this purpose but i am working with lucene.net & c# so please anyone guide me how make it possible to store lucene index in sql server.

thanks

Upvotes: 4

Views: 2403

Answers (1)

AndyPook
AndyPook

Reputation: 2889

It is possible to create a custom Directory but, it is quite painful. I've seen several project try this and fail.

The show stopper for your approach is that the IndexWriter assumes that it has sole access to the Directory. So having multiple machines writing docs to the same Directory is flawed and will break many assumptions.

The best approach is to treat Lucene like a database. You wouldn't expect many machines to all write directly to files of a db. That's why there is a service that the clients talk to (SQL Server, MySql, Postgres etc etc).

Remember Lucene is just a library not a "product". What you need is a service with an api for the machines to talk to.

ElasticSearch has been mentioned elsewhere and it is very good. Highly recommended you look into it. Redundancy, speed, latest features etc (yes it does require the JVM, more accurately the JRE. If you look carefully there is a download/installer that does not also install crapware).

It is also quite straight forward to write a service that self-hosts ASP.net WebAPI and wraps Lucene. Creating a client that talks to it is also quite easy. Just a wrapper around HttpClient. (I have done this several times. Getting a POC working should only take a day or two. But the devil is in the detail.)

Upvotes: 3

Related Questions