[dovecot-cvs] dovecot/src/plugins/fts-lucene lucene-wrapper.cc, 1.1, 1.2

tss at dovecot.org tss at dovecot.org
Tue Oct 24 22:51:06 UTC 2006


Update of /var/lib/cvs/dovecot/src/plugins/fts-lucene
In directory talvi:/tmp/cvs-serv3449

Modified Files:
	lucene-wrapper.cc 
Log Message:
Our field length was set to way too small value. For query keys use key* by
default, or "key key2" if it contains spaces. If the query parser anyway
gives an error, don't bother logging it unless DEBUG is enabled.



Index: lucene-wrapper.cc
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-lucene/lucene-wrapper.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- lucene-wrapper.cc	17 Sep 2006 23:15:54 -0000	1.1
+++ lucene-wrapper.cc	24 Oct 2006 21:51:04 -0000	1.2
@@ -7,6 +7,9 @@
 };
 #include <CLucene.h>
 
+/* Lucene's default is 10000. Use it here also.. */
+#define MAX_TERMS_PER_DOCUMENT 10000
+
 using namespace lucene::document;
 using namespace lucene::index;
 using namespace lucene::search;
@@ -163,7 +166,7 @@
 		return -1;
 	}
 
-	index->writer->setMaxFieldLength(MAX_INT_STRLEN);
+	index->writer->setMaxFieldLength(MAX_TERMS_PER_DOCUMENT);
 	return 0;
 }
 
@@ -276,7 +279,9 @@
 		return -1;
 
 	t_push();
-	quoted_key = t_strdup_printf("\"%s\"", key);
+	quoted_key = strchr(key, ' ') == NULL ?
+		t_strdup_printf("%s*", key) :
+		t_strdup_printf("\"%s\"", key);
 	unsigned int len = utf8_strlen_n(quoted_key, (size_t)-1);
 	wchar_t tkey[len + 1];
 	lucene_utf8towcs(tkey, quoted_key, len + 1);
@@ -287,8 +292,10 @@
 		query = QueryParser::parse(tkey, _T("contents"),
 					   index->analyzer);
 	} catch (CLuceneError &err) {
-		i_error("lucene: QueryParser::parse(%s) failed: %s",
-			str_sanitize(key, 40), err.what());
+		if (getenv("DEBUG") != NULL) {
+			i_info("lucene: QueryParser::parse(%s) failed: %s",
+			       str_sanitize(key, 40), err.what());
+		}
 		lucene_index_close(index);
 		return -1;
 	}



More information about the dovecot-cvs mailing list