From: Timo Sirainen Date: Tue, 22 Jun 2010 21:41:55 +0000 (+0100) Subject: fts-solr: Fixed handling indexing for multiple body parts. X-Git-Tag: 2.0.rc1~102 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ac70848c2999dc3eac50d3bc1c4a07eef0d1189;p=thirdparty%2Fdovecot%2Fcore.git fts-solr: Fixed handling indexing for multiple body parts. --HG-- branch : HEAD --- diff --git a/src/plugins/fts-solr/fts-backend-solr.c b/src/plugins/fts-solr/fts-backend-solr.c index d4b9c7ac6d..432c927e52 100644 --- a/src/plugins/fts-solr/fts-backend-solr.c +++ b/src/plugins/fts-solr/fts-backend-solr.c @@ -29,6 +29,7 @@ struct solr_fts_backend_build_context { uint32_t prev_uid, uid_validity; string_t *cmd; bool headers; + bool field_open; }; struct solr_virtual_uid_map_context { @@ -569,7 +570,11 @@ fts_backend_solr_uid_changed(struct solr_fts_backend_build_context *ctx, ctx->post = solr_connection_post_begin(solr_conn); str_append(ctx->cmd, ""); } else { - str_append(ctx->cmd, ""); + if (ctx->field_open) { + str_append(ctx->cmd, ""); + ctx->field_open = FALSE; + } + str_append(ctx->cmd, ""); } ctx->prev_uid = uid; ctx->headers = FALSE; @@ -591,9 +596,15 @@ fts_backend_solr_build_hdr(struct fts_backend_build_context *_ctx, fts_backend_solr_uid_changed(ctx, uid); else { i_assert(!ctx->headers); - str_append(ctx->cmd, ""); + + if (ctx->field_open) { + str_append(ctx->cmd, ""); + ctx->field_open = FALSE; + } } + i_assert(!ctx->field_open); + ctx->field_open = TRUE; ctx->headers = TRUE; str_append(ctx->cmd, ""); } @@ -616,6 +627,8 @@ fts_backend_solr_build_body_begin(struct fts_backend_build_context *_ctx, i_assert(!ctx->headers); } + i_assert(!ctx->field_open); + ctx->field_open = TRUE; ctx->headers = FALSE; str_append(ctx->cmd, ""); return TRUE; @@ -645,7 +658,11 @@ fts_backed_solr_build_commit(struct solr_fts_backend_build_context *ctx) if (ctx->post == NULL) return 0; - str_append(ctx->cmd, ""); + if (ctx->field_open) { + str_append(ctx->cmd, ""); + ctx->field_open = FALSE; + } + str_append(ctx->cmd, ""); /* Update the mailbox's last_uid field, replacing the existing document. Note that since there is no locking, it's possible that