Firebird SQL (excellent embedded database with a good .NET support) has no built-in fulltext search support so far. Instead, you need to rely on third party tools. Fortunately, there is a great search engine library available: DotLucene. It is an open-source .NET library (ported from Java) that can index any data (structured or unstructured) that you are able to convert to raw text. Using an additional library for fulltext doesn't look too elegant at first sight. However, it has some advantages. Let's compare it quickly with MySQL integrated fulltext search:
MySQL fulltext search has these drawbacks (compared to DotLucene):
For basics about using DotLucene to index your data, I recommend reading:
The following applies for indexing the database:
On a server, it's no problem to store the index in a separate directory (you can also load it to RAM to make your searches super fast - if you have enough RAM, of course). In a desktop application, it might be useful to store the index in a Firebird database.
DotLucene supports a mechanism for adding custom index storages. All storage types (file system and RAM are built-in) are implemented as a class derived from Lucene.Net.Store.Directory abstract class. I have created a Directory implementation that stores the index directly in a Firebird SQL database.
All index reading/writing operations in DotLucene are done using a Directory class. The new FbDirectory class is based on FSDirectory. The filesystem operations are replaced with database operations. Here you can see what we need to implement:
using System;
namespace Lucene.Net.Store
{
public abstract class Directory
{
public abstract String[] List();
public abstract bool FileExists(String name);
public abstract long FileModified(String name);
public abstract void TouchFile(String name);
public abstract void DeleteFile(String name);
public abstract void RenameFile(String from, String to);
public abstract long FileLength(String name);
public abstract OutputStream CreateFile(String name);
public abstract InputStream OpenFile(String name);
public abstract Lock MakeLock(String name);
public abstract void Close();
}
}
FbDirectory.Copy(); This will only help you if you are rebuilding the whole index from scratch.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||