lucene-wrapper.cc revision 7bc564062f3bef44c61f4e83ccdd9c5eaa433253
/* Copyright (C) 2006 Timo Sirainen */
extern "C" {
#include "lib.h"
#include "unichar.h"
#include "str-sanitize.h"
#include "lucene-wrapper.h"
};
#include <CLucene.h>
/* Lucene's default is 10000. Use it here also.. */
#define MAX_TERMS_PER_DOCUMENT 10000
using namespace lucene::queryParser;
struct lucene_index {
char *path;
char *mailbox_name;
};
class RawTokenStream : public TokenStream {
public:
};
if (len <= 0)
return false;
return true;
}
void close() { }
};
public:
/* Everything except contents should go as-is without any
modifications. Isn't there any easier way to do this than
to implement a whole new RawTokenStream?.. */
return standard::StandardAnalyzer::
}
};
{
struct lucene_index *index;
return index;
}
{
}
{
}
const char *mailbox_name)
{
}
{
return 1;
return 0;
try {
} catch (CLuceneError &err) {
return -1;
}
return 1;
}
{
int ret;
return 1;
return ret;
return 1;
}
static int
{
i_error("lucene: Corrupted FTS index %s: No UID for document",
return -1;
}
while (*uid != 0) {
uid++;
}
return 0;
}
static int
{
int ret = 0;
bool deleted = false;
return ret;
/* find all the existing last_uids for selected mailbox.
if there are more than one, delete the smaller ones. this is normal
we'll do it only in here.. */
try {
ret = -1;
break;
}
if (last_doc_id >= 0)
} else {
}
if (del_id >= 0 && delete_old) {
deleted = true;
}
}
} catch (CLuceneError &err) {
ret = -1;
}
if (deleted) {
/* the index was modified. we'll need to release the locks
before opening a writer */
}
return ret;
}
{
/* delete the old last_uids in here, since we've not write-locked
the index yet */
if (lucene_index_get_last_uid_int(index, true) < 0)
return -1;
return 0;
}
{
try {
} catch (CLuceneError &err) {
i_error("lucene: IndexWriter(%s) failed: %s",
return -1;
}
if (lucene_index_get_last_uid_int(index, false) < 0)
return -1;
return 0;
}
{
int ret = 0;
return 0;
try {
} catch (CLuceneError &err) {
i_error("lucene: IndexWriter::addDocument(%s) failed: %s",
ret = -1;
}
return ret;
}
{
unsigned int len;
char id[MAX_INT_STRLEN];
char id[MAX_INT_STRLEN];
if (lucene_index_build_flush(index) < 0)
return -1;
}
/* note that each addDocument() call adds a new document with a new
internal ID to the database. */
return 0;
}
{
char id[MAX_INT_STRLEN];
try {
return 0;
} catch (CLuceneError &err) {
i_error("lucene: IndexWriter::addDocument(%s) failed: %s",
return -1;
}
}
{
int ret = 0;
/* no changes. */
return 0;
}
return -1;
}
if (lucene_index_build_flush(index) < 0)
ret = -1;
if (lucene_index_update_last_uid(index) < 0)
ret = -1;
try {
} catch (CLuceneError &err) {
i_error("lucene: IndexWriter::optimize(%s) failed: %s",
ret = -1;
}
try {
} catch (CLuceneError &err) {
i_error("lucene: IndexWriter::close(%s) failed: %s",
ret = -1;
}
return ret;
}
{
char id[MAX_INT_STRLEN];
int ret;
return ret;
try {
return 0;
} catch (CLuceneError &err) {
return -1;
}
}
{
const char *quoted_key;
int ret = 0;
if (lucene_index_open_search(index) <= 0)
return -1;
t_push();
t_pop();
try {
} catch (CLuceneError &err) {
i_info("lucene: QueryParser::parse(%s) failed: %s",
}
return -1;
}
try {
ret = -1;
break;
}
}
} catch (CLuceneError &err) {
i_error("lucene: search(%s) failed: %s",
ret = -1;
}
return ret;
}