changeset 20273:105e82862423

lib-storage: add no_fts in struct mail_search_arg When flag is set, FTS will not be performed. fts plugin: handle no_fts flag No fts will be performed once flag is set. Original patch from Timo Sirainen <timo.sirainen@dovecot.fi>
author Baofeng Wang <baofeng.wang@dovecot.fi>
date Wed, 18 May 2016 14:42:21 +0300
parents 3d60b96543fd
children 9db5ba11dccc
files src/lib-storage/mail-search.h src/plugins/fts-lucene/lucene-wrapper.cc src/plugins/fts-solr/fts-backend-solr-old.c src/plugins/fts-solr/fts-backend-solr.c src/plugins/fts/fts-api.c src/plugins/fts/fts-storage.c
diffstat 6 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-search.h	Mon May 30 19:07:16 2016 +0300
+++ b/src/lib-storage/mail-search.h	Wed May 18 14:42:21 2016 +0300
@@ -101,6 +101,7 @@
 	unsigned int match_always:1; /* result = 1 always */
 	unsigned int nonmatch_always:1; /* result = 0 always */
 	unsigned int fuzzy:1; /* use fuzzy matching for this arg */
+	unsigned int no_fts:1; /* do NOT call FTS */
 
 	int result; /* -1 = unknown, 0 = unmatched, 1 = matched */
 };
--- a/src/plugins/fts-lucene/lucene-wrapper.cc	Mon May 30 19:07:16 2016 +0300
+++ b/src/plugins/fts-lucene/lucene-wrapper.cc	Wed May 18 14:42:21 2016 +0300
@@ -1200,6 +1200,9 @@
 	bool and_args = (flags & FTS_LOOKUP_FLAG_AND_ARGS) != 0;
 	Query *q;
 
+	if (arg->no_fts)
+		return false;
+
 	if (arg->match_not && !and_args) {
 		/* FIXME: we could handle this by doing multiple queries.. */
 		return false;
@@ -1266,6 +1269,9 @@
 	bool and_args = (flags & FTS_LOOKUP_FLAG_AND_ARGS) != 0;
 	Query *q = NULL;
 
+	if (arg->no_fts)
+		return false;
+
 	if (arg->match_not) {
 		/* FIXME: we could handle this by doing multiple queries.. */
 		return false;
--- a/src/plugins/fts-solr/fts-backend-solr-old.c	Mon May 30 19:07:16 2016 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr-old.c	Wed May 18 14:42:21 2016 +0300
@@ -630,6 +630,8 @@
 static bool
 solr_add_definite_query(string_t *str, struct mail_search_arg *arg)
 {
+	if (arg->no_fts)
+		return FALSE;
 	switch (arg->type) {
 	case SEARCH_TEXT: {
 		if (arg->match_not)
--- a/src/plugins/fts-solr/fts-backend-solr.c	Mon May 30 19:07:16 2016 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr.c	Wed May 18 14:42:21 2016 +0300
@@ -664,6 +664,8 @@
 static bool
 solr_add_definite_query(string_t *str, struct mail_search_arg *arg)
 {
+	if (arg->no_fts)
+		return FALSE;
 	switch (arg->type) {
 	case SEARCH_TEXT: {
 		if (arg->match_not)
@@ -726,6 +728,8 @@
 static bool
 solr_add_maybe_query(string_t *str, struct mail_search_arg *arg)
 {
+	if (arg->no_fts)
+		return FALSE;
 	switch (arg->type) {
 	case SEARCH_HEADER:
 	case SEARCH_HEADER_ADDRESS:
--- a/src/plugins/fts/fts-api.c	Mon May 30 19:07:16 2016 +0300
+++ b/src/plugins/fts/fts-api.c	Wed May 18 14:42:21 2016 +0300
@@ -315,7 +315,9 @@
 		case SEARCH_HEADER_COMPRESS_LWSP:
 		case SEARCH_BODY:
 		case SEARCH_TEXT:
-			return TRUE;
+			if (!args->no_fts)
+				return TRUE;
+			break;
 		default:
 			break;
 		}
--- a/src/plugins/fts/fts-storage.c	Mon May 30 19:07:16 2016 +0300
+++ b/src/plugins/fts/fts-storage.c	Wed May 18 14:42:21 2016 +0300
@@ -154,7 +154,9 @@
 			break;
 		case SEARCH_BODY:
 		case SEARCH_TEXT:
-			return TRUE;
+			if (!args->no_fts)
+				return TRUE;
+			break;
 		default:
 			break;
 		}