fts-backend-solr.c revision 98b510006a8fbab215d9ab4a3b311e25488d5d0f
/* Copyright (c) 2006-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "mail-storage-private.h"
#include "mail-namespace.h"
#include "solr-connection.h"
#include "fts-solr-plugin.h"
#define SOLR_MAX_ROWS 100000
struct solr_fts_backend {
struct fts_backend backend;
char *id_username;
};
struct solr_fts_backend_build_context {
struct fts_backend_build_context ctx;
struct solr_connection_post *post;
bool headers;
};
{
}
static void
{
unsigned int i;
for (i = 0; i < len; i++) {
switch (data[i]) {
case '&':
break;
case '<':
break;
case '>':
break;
default:
break;
}
}
}
{
}
static const char *solr_escape_id_str(const char *str)
{
const char *p;
for (p = str; *p != '\0'; p++) {
if (*p == '/' || *p == '!')
break;
}
if (*p == '\0')
return str;
for (p = str; *p != '\0'; p++) {
switch (*p) {
case '/':
break;
case '!':
break;
default:
str_append_c(tmp, *p);
break;
}
}
}
static struct fts_backend *
{
struct solr_fts_backend *backend;
if (set->substring_search)
}
{
}
{
return backend->id_username;
}
{
struct mailbox_status status;
unsigned int count;
return -1;
if (count == 0) {
/* nothing indexed yet for this mailbox */
*last_uid_r = 0;
} else {
i_error("fts_solr: Last UID lookup returned multiple rows");
return -1;
}
return 0;
}
{
struct mailbox_status status;
unsigned int count;
return -1;
if (count == 0) {
/* either nothing is indexed or we're converting from an
older database format without the last_uid fields */
} else {
i_error("fts_solr: Last UID lookup returned multiple rows");
return -1;
}
return 0;
}
static int
struct fts_backend_build_context **ctx_r)
{
struct solr_fts_backend_build_context *ctx;
struct mailbox_status status;
return 0;
}
static void
{
"<field name=\"uid\">%u</field>"
"<field name=\"uidv\">%u</field>",
}
static int
{
struct solr_fts_backend_build_context *ctx =
(struct solr_fts_backend_build_context *)_ctx;
/* body comes first, then headers */
/* uid changed */
else
if (headers) {
} else {
}
} else {
}
str_truncate(cmd, 0);
}
return 0;
}
static int
{
int ret;
return 0;
/* Update the mailbox's last_uid field, replacing the existing
document. Note that since there is no locking, it's possible that
if another session is indexing at the same time, the last_uid value
may shrink. This doesn't really matter, we'll simply do more work
in future by reindexing some messages. */
/* commit and wait until the documents we just indexed are
visible to the following search */
"waitSearcher=\"true\"/>") < 0)
ret = -1;
return ret;
}
static int
{
struct solr_fts_backend_build_context *ctx =
(struct solr_fts_backend_build_context *)_ctx;
int ret;
return ret;
}
static void
{
struct mailbox_status status;
T_BEGIN {
} T_END;
}
static void
bool committed ATTR_UNUSED)
{
"<commit waitFlush=\"false\" waitSearcher=\"false\"/>");
}
{
return 1;
}
{
}
{
}
{
const struct fts_backend_lookup_field *fields;
unsigned int i, count;
struct mailbox_status status;
bool virtual;
if (!virtual) {
} else {
"&sort=box%%20asc,uid%%20asc&q=",
}
/* build a lucene search query from the fields */
for (i = 0; i < count; i++) {
if (i > 0)
/* body only */
/* header only */
} else {
/* both */
}
}
/* use a separate filter query for selecting the mailbox. it shouldn't
affect the score and there could be some caching benefits too. */
/* FIXME: limit what mailboxes to search with virtual storage */
if (!virtual) {
}
if (!virtual) {
} else {
}
}
struct fts_backend fts_backend_solr = {
{
NULL,
NULL,
}
};