dovecot-2.1: fts-lucene: Optimize searching for existence of an ...

dovecot at dovecot.org dovecot at dovecot.org
Sat Nov 5 17:21:28 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/efe369e2885d
changeset: 13659:efe369e2885d
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Nov 05 17:31:47 2011 +0200
description:
fts-lucene: Optimize searching for existence of an indexed header.

diffstat:

 src/plugins/fts-lucene/lucene-wrapper.cc |  24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diffs (54 lines):

diff -r 6e7658437688 -r efe369e2885d src/plugins/fts-lucene/lucene-wrapper.cc
--- a/src/plugins/fts-lucene/lucene-wrapper.cc	Sat Nov 05 17:30:55 2011 +0200
+++ b/src/plugins/fts-lucene/lucene-wrapper.cc	Sat Nov 05 17:31:47 2011 +0200
@@ -1082,12 +1082,9 @@
 	case SEARCH_HEADER:
 	case SEARCH_HEADER_ADDRESS:
 	case SEARCH_HEADER_COMPRESS_LWSP:
-		if (!fts_header_want_indexed(arg->hdr_field_name))
+		if (!fts_header_want_indexed(arg->hdr_field_name) ||
+		    *arg->value.str == '\0')
 			return false;
-		if (*arg->value.str == '\0') {
-			/* FIXME: handle existence of a search key */
-			return false;
-		}
 
 		q = lucene_get_query(index,
 				     t_lucene_utf8_to_tchar(index, arg->hdr_field_name, FALSE),
@@ -1115,7 +1112,7 @@
 lucene_add_maybe_query(struct lucene_index *index, BooleanQuery &query,
 		       struct mail_search_arg *arg, bool and_args)
 {
-	Query *q;
+	Query *q = NULL;
 
 	if (arg->match_not && !and_args) {
 		/* FIXME: we could handle this by doing multiple queries.. */
@@ -1126,18 +1123,19 @@
 	case SEARCH_HEADER:
 	case SEARCH_HEADER_ADDRESS:
 	case SEARCH_HEADER_COMPRESS_LWSP:
+		if (*arg->value.str == '\0') {
+			/* checking potential existence of the header name */
+			q = lucene_get_query_str(index, _T("hdr"),
+						 arg->hdr_field_name, FALSE);
+			break;
+		}
+
 		if (fts_header_want_indexed(arg->hdr_field_name))
 			return false;
 
 		/* we can check if the search key exists in some header and
 		   filter out the messages that have no chance of matching */
-		if (*arg->value.str != '\0')
-			q = lucene_get_query(index, _T("hdr"), arg);
-		else {
-			/* checking potential existence of the header name */
-			q = lucene_get_query_str(index, _T("hdr"),
-						 arg->hdr_field_name, FALSE);
-		}
+		q = lucene_get_query(index, _T("hdr"), arg);
 		break;
 	default:
 		return false;


More information about the dovecot-cvs mailing list