]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts-solr: Add soft_commit setting
authorJohn Fawcett <john@voipsupport.it>
Wed, 24 Apr 2019 07:37:55 +0000 (10:37 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 29 Apr 2019 11:54:57 +0000 (11:54 +0000)
soft_commit=yes|no: send softCommit to the solr server, default yes is backwards compatible behaviour
If setting to no autoSoftCommit on solr should be set to something reasonable (e.g. 60 seconds)
in file solrconfig.xml

src/plugins/fts-solr/fts-backend-solr.c
src/plugins/fts-solr/fts-solr-plugin.c
src/plugins/fts-solr/fts-solr-plugin.h

index 767289adc974ee35ea5f8e1f68463c212cce5473..d3f890e36e513f93c51358d36890bf6b69aab762 100644 (file)
@@ -402,10 +402,12 @@ fts_backend_solr_update_deinit(struct fts_backend_update_context *_ctx)
                   visible to the following search */
                if (ctx->expunges)
                        fts_backend_solr_expunge_flush(ctx);
-               str = t_strdup_printf("<commit softCommit=\"true\" waitSearcher=\"%s\"/>",
-                                     ctx->documents_added ? "true" : "false");
-               if (solr_connection_post(backend->solr_conn, str) < 0)
-                       ret = -1;
+               if (fuser->set.soft_commit) {
+                       str = t_strdup_printf("<commit softCommit=\"true\" waitSearcher=\"%s\"/>",
+                                             ctx->documents_added ? "true" : "false");
+                       if (solr_connection_post(backend->solr_conn, str) < 0)
+                               ret = -1;
+               }
        }
 
        str_free(&ctx->cmd);
index cf01e15c32965b7ebc8974369676a316bbf6e09f..124269213176c96fe9e98517be8a64518d82bf8d 100644 (file)
@@ -27,6 +27,7 @@ fts_solr_plugin_init_settings(struct mail_user *user,
                str = "";
 
        set->batch_size = DEFAULT_SOLR_BATCH_SIZE;
+       set->soft_commit = TRUE;
 
        for (tmp = t_strsplit_spaces(str, " "); *tmp != NULL; tmp++) {
                if (str_begins(*tmp, "url=")) {
@@ -46,6 +47,15 @@ fts_solr_plugin_init_settings(struct mail_user *user,
                                i_error("fts_solr: batch_size must be a positive integer");
                                        return -1;
                        }
+               } else if (str_begins(*tmp, "soft_commit=")) {
+                       if (strcmp(*tmp + 12, "yes") == 0) {
+                               set->soft_commit = TRUE;
+                       } else if (strcmp(*tmp + 12, "no") == 0) {
+                               set->soft_commit = FALSE;
+                       } else {
+                               i_error("fts_solr: Invalid setting for soft_commit: %s", *tmp+12);
+                               return -1;
+                       }
                } else {
                        i_error("fts_solr: Invalid setting: %s", *tmp);
                        return -1;
index 506b2e8947b5d9f8475024a7ef2d20d8a632828c..abc1b66932288f4a9231ecde920f752b35de9bb2 100644 (file)
@@ -15,6 +15,7 @@ struct fts_solr_settings {
        unsigned int batch_size;
        bool use_libfts;
        bool debug;
+       bool soft_commit;
 };
 
 struct fts_solr_user {