[dovecot-cvs] dovecot/src/plugins/fts fts-api-private.h, 1.8, 1.9 fts-api.c, 1.9, 1.10 fts-api.h, 1.7, 1.8 fts-storage.c, 1.16, 1.17
tss at dovecot.org
tss at dovecot.org
Fri Mar 16 00:20:59 EET 2007
Update of /var/lib/cvs/dovecot/src/plugins/fts
In directory talvi:/tmp/cvs-serv30017/fts
Modified Files:
fts-api-private.h fts-api.c fts-api.h fts-storage.c
Log Message:
Separate headers and body in building and searching. Added support for
Lucene to index/search them separately.
Index: fts-api-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api-private.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- fts-api-private.h 20 Dec 2006 21:26:37 -0000 1.8
+++ fts-api-private.h 15 Mar 2007 22:20:55 -0000 1.9
@@ -13,7 +13,7 @@
(*build_init)(struct fts_backend *backend,
uint32_t *last_uid_r);
int (*build_more)(struct fts_backend_build_context *ctx, uint32_t uid,
- const unsigned char *data, size_t size);
+ const unsigned char *data, size_t size, bool headers);
int (*build_deinit)(struct fts_backend_build_context *ctx);
void (*expunge)(struct fts_backend *backend, struct mail *mail);
@@ -23,10 +23,10 @@
int (*lock)(struct fts_backend *backend);
void (*unlock)(struct fts_backend *backend);
- int (*lookup)(struct fts_backend *backend, const char *key,
- ARRAY_TYPE(seq_range) *result);
- int (*filter)(struct fts_backend *backend, const char *key,
- ARRAY_TYPE(seq_range) *result);
+ int (*lookup)(struct fts_backend *backend, enum fts_lookup_flags flags,
+ const char *key, ARRAY_TYPE(seq_range) *result);
+ int (*filter)(struct fts_backend *backend, enum fts_lookup_flags flags,
+ const char *key, ARRAY_TYPE(seq_range) *result);
};
enum fts_backend_flags {
Index: fts-api.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- fts-api.c 20 Dec 2006 14:46:22 -0000 1.9
+++ fts-api.c 15 Mar 2007 22:20:55 -0000 1.10
@@ -67,9 +67,9 @@
}
int fts_backend_build_more(struct fts_backend_build_context *ctx, uint32_t uid,
- const unsigned char *data, size_t size)
+ const unsigned char *data, size_t size, bool headers)
{
- return ctx->backend->v.build_more(ctx, uid, data, size);
+ return ctx->backend->v.build_more(ctx, uid, data, size, headers);
}
int fts_backend_build_deinit(struct fts_backend_build_context *ctx)
@@ -98,24 +98,24 @@
backend->v.unlock(backend);
}
-int fts_backend_lookup(struct fts_backend *backend, const char *key,
- ARRAY_TYPE(seq_range) *result)
+int fts_backend_lookup(struct fts_backend *backend, enum fts_lookup_flags flags,
+ const char *key, ARRAY_TYPE(seq_range) *result)
{
- return backend->v.lookup(backend, key, result);
+ return backend->v.lookup(backend, flags, key, result);
}
-int fts_backend_filter(struct fts_backend *backend, const char *key,
- ARRAY_TYPE(seq_range) *result)
+int fts_backend_filter(struct fts_backend *backend, enum fts_lookup_flags flags,
+ const char *key, ARRAY_TYPE(seq_range) *result)
{
ARRAY_TYPE(seq_range) tmp_result;
int ret;
if (backend->v.filter != NULL)
- return backend->v.filter(backend, key, result);
+ return backend->v.filter(backend, flags, key, result);
/* do this ourself */
i_array_init(&tmp_result, 64);
- ret = fts_backend_lookup(backend, key, &tmp_result);
+ ret = fts_backend_lookup(backend, flags, key, &tmp_result);
if (ret == 0) {
const struct seq_range *range;
unsigned int i, count;
Index: fts-api.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- fts-api.h 6 Dec 2006 15:45:15 -0000 1.7
+++ fts-api.h 15 Mar 2007 22:20:55 -0000 1.8
@@ -6,6 +6,11 @@
#include "seq-range-array.h"
+enum fts_lookup_flags {
+ FTS_LOOKUP_FLAG_HEADERS = 0x01,
+ FTS_LOOKUP_FLAG_BODY = 0x02
+};
+
struct fts_backend *
fts_backend_init(const char *backend_name, struct mailbox *box);
void fts_backend_deinit(struct fts_backend *backend);
@@ -19,9 +24,11 @@
fts_backend_build_init(struct fts_backend *backend, uint32_t *last_uid_r);
/* Add more contents to the index. The data must contain only full valid
UTF-8 characters, but it doesn't need to be NUL-terminated. size contains
- the data size in bytes, not characters. */
+ the data size in bytes, not characters. headers is TRUE if the data contains
+ message headers instead of message body. */
int fts_backend_build_more(struct fts_backend_build_context *ctx, uint32_t uid,
- const unsigned char *data, size_t size);
+ const unsigned char *data, size_t size,
+ bool headers);
/* Finish adding new data to the index. */
int fts_backend_build_deinit(struct fts_backend_build_context *ctx);
@@ -41,12 +48,12 @@
void fts_backend_unlock(struct fts_backend *backend);
/* Lookup key from the index and return the found UIDs in result. */
-int fts_backend_lookup(struct fts_backend *backend, const char *key,
- ARRAY_TYPE(seq_range) *result);
+int fts_backend_lookup(struct fts_backend *backend, enum fts_lookup_flags flags,
+ const char *key, ARRAY_TYPE(seq_range) *result);
/* Drop UIDs from the result list for which the key doesn't exist. The idea
is that with multiple search keywords you first lookup one and then filter
the rest. */
-int fts_backend_filter(struct fts_backend *backend, const char *key,
- ARRAY_TYPE(seq_range) *result);
+int fts_backend_filter(struct fts_backend *backend, enum fts_lookup_flags flags,
+ const char *key, ARRAY_TYPE(seq_range) *result);
#endif
Index: fts-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-storage.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- fts-storage.c 21 Dec 2006 15:20:59 -0000 1.16
+++ fts-storage.c 15 Mar 2007 22:20:55 -0000 1.17
@@ -110,7 +110,7 @@
return 1;
if (fts_backend_build_more(ctx->build, ctx->uid, str_data(ctx->headers),
- str_len(ctx->headers)) < 0)
+ str_len(ctx->headers), TRUE) < 0)
return -1;
str_truncate(ctx->headers, 0);
@@ -210,8 +210,8 @@
}
} else {
if (fts_backend_build_more(ctx->build, ctx->mail->uid,
- block.data,
- block.size) < 0) {
+ block.data, block.size,
+ FALSE) < 0) {
ret = -1;
break;
}
@@ -366,6 +366,7 @@
ARRAY_TYPE(seq_range) *uid_result)
{
const char *key;
+ enum fts_lookup_flags flags;
for (; args != NULL; args = args->next) {
switch (args->type) {
@@ -392,7 +393,11 @@
key = args->hdr_field_name;
}
- if (fts_backend_filter(fctx->backend, key,
+ flags = FTS_LOOKUP_FLAG_BODY;
+ if (args->type == SEARCH_TEXT_FAST ||
+ args->type == SEARCH_TEXT)
+ flags |= FTS_LOOKUP_FLAG_HEADERS;
+ if (fts_backend_filter(fctx->backend, flags, key,
uid_result) < 0) {
/* failed, but we already have limited
the search, so just ignore this */
@@ -420,6 +425,7 @@
struct fts_search_context *fctx)
{
struct fts_backend *backend = fctx->backend;
+ enum fts_lookup_flags flags;
const char *key;
ARRAY_TYPE(seq_range) uid_result;
@@ -433,11 +439,17 @@
/* we're only checking the existence
of the header. */
+ flags = FTS_LOOKUP_FLAG_HEADERS;
key = fctx->best_arg->hdr_field_name;
+ } else {
+ flags = FTS_LOOKUP_FLAG_BODY;
+ if (fctx->best_arg->type == SEARCH_TEXT_FAST ||
+ fctx->best_arg->type == SEARCH_TEXT)
+ flags |= FTS_LOOKUP_FLAG_HEADERS;
}
i_array_init(&uid_result, 64);
- if (fts_backend_lookup(backend, key, &uid_result) < 0) {
+ if (fts_backend_lookup(backend, flags, key, &uid_result) < 0) {
/* failed, fallback to reading everything */
array_free(&uid_result);
return;
More information about the dovecot-cvs
mailing list