Skip to content

Add new config options for fts_solr #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/plugins/fts-solr/fts-backend-solr.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,21 +510,39 @@ fts_backend_solr_update_set_build_key(struct fts_backend_update_context *_ctx,
{
struct solr_fts_backend_update_context *ctx =
(struct solr_fts_backend_update_context *)_ctx;
struct solr_fts_backend *backend = (struct solr_fts_backend *)ctx->ctx.backend;
struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(backend->backend.ns->user);

if (key->uid != ctx->prev_uid)
fts_backend_solr_uid_changed(ctx, key->uid);

switch (key->type) {
case FTS_BACKEND_BUILD_KEY_HDR:
bool want_indexed = FALSE;
bool want_hdr = TRUE;
if (key->type == FTS_BACKEND_BUILD_KEY_HDR || key->type == FTS_BACKEND_BUILD_KEY_MIME_HDR) {
if (fts_header_want_indexed(key->hdr_name)) {
ctx->cur_value2 =
fts_solr_field_get(ctx, key->hdr_name);
want_indexed = TRUE;
} else if (fuser->set.limit_mime_hdr) {
want_hdr = FALSE;
}

if (!want_indexed && !want_hdr) {
return FALSE;
}
}

switch (key->type) {
case FTS_BACKEND_BUILD_KEY_HDR:
if (want_indexed)
ctx->cur_value2 = fts_solr_field_get(ctx, key->hdr_name);
/* fall through */
case FTS_BACKEND_BUILD_KEY_MIME_HDR:
ctx->cur_value = fts_solr_field_get(ctx, "hdr");
xml_encode(ctx->cur_value, key->hdr_name);
str_append(ctx->cur_value, ": ");
if (want_hdr) {
if(!fuser->set.skip_mime_hdr_fieldname) {
xml_encode(ctx->cur_value, key->hdr_name);
str_append(ctx->cur_value, ": ");
}
}
break;
case FTS_BACKEND_BUILD_KEY_BODY_PART:
if (!ctx->body_open) {
Expand Down Expand Up @@ -843,7 +861,7 @@ fts_backend_solr_lookup(struct fts_backend *_backend, struct mailbox *box,
if (solr_search(_backend, str, box_guid,
&result->maybe_uids, &result->scores) < 0)
return -1;
}
}
result->scores_sorted = TRUE;
return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/fts-solr/fts-solr-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ fts_solr_plugin_init_settings(struct mail_user *user,
} else if (strcmp(*tmp, "default_ns=") == 0) {
set->default_ns_prefix =
p_strdup(user->pool, *tmp + 11);
} else if (strcmp(*tmp, "limit_mime_hdr") == 0) {
set->limit_mime_hdr = TRUE;
} else if (strcmp(*tmp, "skip_mime_hdr_fieldname") == 0) {
set->skip_mime_hdr_fieldname = TRUE;
} else {
i_error("fts_solr: Invalid setting: %s", *tmp);
return -1;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/fts-solr/fts-solr-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct fts_solr_settings {
const char *url, *default_ns_prefix;
bool use_libfts;
bool debug;
bool limit_mime_hdr;
bool skip_mime_hdr_fieldname;
};

struct fts_solr_user {
Expand Down