uint32_t prev_uid, uid_validity;
string_t *cmd;
bool headers;
+ bool field_open;
};
struct solr_virtual_uid_map_context {
ctx->post = solr_connection_post_begin(solr_conn);
str_append(ctx->cmd, "<add>");
} else {
- str_append(ctx->cmd, "</field></doc>");
+ if (ctx->field_open) {
+ str_append(ctx->cmd, "</field>");
+ ctx->field_open = FALSE;
+ }
+ str_append(ctx->cmd, "</doc>");
}
ctx->prev_uid = uid;
ctx->headers = FALSE;
fts_backend_solr_uid_changed(ctx, uid);
else {
i_assert(!ctx->headers);
- str_append(ctx->cmd, "</field>");
+
+ if (ctx->field_open) {
+ str_append(ctx->cmd, "</field>");
+ ctx->field_open = FALSE;
+ }
}
+ i_assert(!ctx->field_open);
+ ctx->field_open = TRUE;
ctx->headers = TRUE;
str_append(ctx->cmd, "<field name=\"hdr\">");
}
i_assert(!ctx->headers);
}
+ i_assert(!ctx->field_open);
+ ctx->field_open = TRUE;
ctx->headers = FALSE;
str_append(ctx->cmd, "<field name=\"body\">");
return TRUE;
if (ctx->post == NULL)
return 0;
- str_append(ctx->cmd, "</field></doc>");
+ if (ctx->field_open) {
+ str_append(ctx->cmd, "</field>");
+ ctx->field_open = FALSE;
+ }
+ str_append(ctx->cmd, "</doc>");
/* Update the mailbox's last_uid field, replacing the existing
document. Note that since there is no locking, it's possible that