return FALSE;
}
+static enum fts_enforced fts_enforced_parse(const char *str)
+{
+ if (str == NULL || strcmp(str, "no") == 0)
+ return FTS_ENFORCED_NO;
+ else if (strcmp(str, "body") == 0)
+ return FTS_ENFORCED_BODY;
+ else
+ return FTS_ENFORCED_YES;
+}
+
static struct mail_search_context *
fts_mailbox_search_init(struct mailbox_transaction_context *t,
struct mail_search_args *args,
fctx->result_pool = pool_alloconly_create("fts results", 1024*64);
fctx->orig_matches = buffer_create_dynamic(default_pool, 64);
fctx->virtual_mailbox = t->box->virtual_vfuncs != NULL;
- fctx->enforced =
- mail_user_plugin_getenv_bool(t->box->storage->user,
- "fts_enforced");
+ fctx->enforced = fts_enforced_parse(
+ mail_user_plugin_getenv(t->box->storage->user, "fts_enforced"));
i_array_init(&fctx->levels, 8);
fctx->scores = i_new(struct fts_scores, 1);
fctx->scores->refcount = 1;
ft->scores = fctx->scores;
ft->scores->refcount++;
- if (fctx->enforced || fts_want_build_args(args->args))
+ if (fctx->enforced == FTS_ENFORCED_YES ||
+ fts_want_build_args(args->args))
fts_try_build_init(ctx, fctx);
else
fts_search_lookup(fctx);
return FALSE;
}
}
- if (fctx != NULL && !fctx->fts_lookup_success && fctx->enforced)
+ if (fctx != NULL && !fctx->fts_lookup_success &&
+ fctx->enforced != FTS_ENFORCED_NO)
return FALSE;
return fbox->module_ctx.super.
}
if (fctx->indexing_timed_out)
ret = -1;
- if (!fctx->fts_lookup_success && fctx->enforced) {
+ if (!fctx->fts_lookup_success &&
+ fctx->enforced != FTS_ENFORCED_NO) {
/* FTS lookup failed and we didn't want to fallback to
opening all the mails and searching manually */
mail_storage_set_internal_error(ctx->transaction->box->storage);
#include "mail-storage-private.h"
#include "fts-api.h"
+enum fts_enforced {
+ FTS_ENFORCED_NO,
+ FTS_ENFORCED_YES,
+ FTS_ENFORCED_BODY,
+};
+
struct fts_scores {
int refcount;
ARRAY_TYPE(fts_score_map) score_map;
struct mailbox_transaction_context *t;
struct mail_search_args *args;
enum fts_lookup_flags flags;
+ enum fts_enforced enforced;
pool_t result_pool;
ARRAY(struct fts_search_level) levels;
bool virtual_mailbox:1;
bool fts_lookup_success:1;
bool indexing_timed_out:1;
- bool enforced:1;
};
/* Figure out if we want to use full text search indexes and update