dovecot-2.1: fts-solr: Fixed indexing messages with multiple MIM...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 8 16:38:07 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/283e08771d92
changeset: 13435:283e08771d92
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 08 16:37:56 2011 +0300
description:
fts-solr: Fixed indexing messages with multiple MIME body parts.
diffstat:
src/plugins/fts-solr/fts-backend-solr-old.c | 18 ++++++++++++++----
src/plugins/fts-solr/fts-backend-solr.c | 19 +++++++++++++++----
2 files changed, 29 insertions(+), 8 deletions(-)
diffs (103 lines):
diff -r 1aa51cd11614 -r 283e08771d92 src/plugins/fts-solr/fts-backend-solr-old.c
--- a/src/plugins/fts-solr/fts-backend-solr-old.c Thu Sep 08 12:39:13 2011 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr-old.c Thu Sep 08 16:37:56 2011 +0300
@@ -36,6 +36,7 @@
string_t *cmd, *hdr;
bool headers_open;
+ bool body_open;
bool documents_added;
};
@@ -513,6 +514,10 @@
str_append(ctx->cmd, "<add>");
} else {
ctx->headers_open = FALSE;
+ if (ctx->body_open) {
+ ctx->body_open = FALSE;
+ str_append(ctx->cmd, "</field>");
+ }
str_append(ctx->cmd, "<field name=\"hdr\">");
str_append_str(ctx->cmd, ctx->hdr);
str_append(ctx->cmd, "</field>");
@@ -547,7 +552,10 @@
break;
case FTS_BACKEND_BUILD_KEY_BODY_PART:
ctx->headers_open = FALSE;
- str_append(ctx->cmd, "<field name=\"body\">");
+ if (!ctx->body_open) {
+ ctx->body_open = TRUE;
+ str_append(ctx->cmd, "<field name=\"body\">");
+ }
break;
case FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY:
i_unreached();
@@ -561,10 +569,12 @@
struct solr_fts_backend_update_context *ctx =
(struct solr_fts_backend_update_context *)_ctx;
- if (!ctx->headers_open)
- str_append(ctx->cmd, "</field>");
- else
+ if (ctx->headers_open)
str_append_c(ctx->hdr, '\n');
+ else {
+ i_assert(ctx->body_open);
+ str_append_c(ctx->cmd, '\n');
+ }
}
static int
diff -r 1aa51cd11614 -r 283e08771d92 src/plugins/fts-solr/fts-backend-solr.c
--- a/src/plugins/fts-solr/fts-backend-solr.c Thu Sep 08 12:39:13 2011 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr.c Thu Sep 08 16:37:56 2011 +0300
@@ -36,6 +36,7 @@
unsigned int last_indexed_uid_set:1;
unsigned int headers_open:1;
+ unsigned int body_open:1;
unsigned int cur_header_index:1;
unsigned int documents_added:1;
unsigned int expunges:1;
@@ -260,6 +261,10 @@
fts_backend_solr_doc_close(struct solr_fts_backend_update_context *ctx)
{
ctx->headers_open = FALSE;
+ if (ctx->body_open) {
+ ctx->body_open = FALSE;
+ str_append(ctx->cmd, "</field>");
+ }
if (str_len(ctx->hdr) > 0) {
str_append(ctx->cmd, "<field name=\"hdr\">");
str_append_str(ctx->cmd, ctx->hdr);
@@ -416,7 +421,10 @@
break;
case FTS_BACKEND_BUILD_KEY_BODY_PART:
ctx->headers_open = FALSE;
- str_append(ctx->cmd, "<field name=\"body\">");
+ if (!ctx->body_open) {
+ ctx->body_open = TRUE;
+ str_append(ctx->cmd, "<field name=\"body\">");
+ }
break;
case FTS_BACKEND_BUILD_KEY_BODY_PART_BINARY:
i_unreached();
@@ -430,12 +438,15 @@
struct solr_fts_backend_update_context *ctx =
(struct solr_fts_backend_update_context *)_ctx;
- if (!ctx->headers_open)
- str_append(ctx->cmd, "</field>");
- else {
+ if (ctx->headers_open) {
/* this is called individually for each header line.
headers are finished only when key changes to body */
str_append_c(ctx->hdr, '\n');
+ } else {
+ i_assert(ctx->body_open);
+ /* messages can have multiple MIME bodies.
+ add them all as one. */
+ str_append_c(ctx->cmd, '\n');
}
if (ctx->cur_header_index) {
More information about the dovecot-cvs
mailing list