#ifndef FTS_API_H
#define FTS_API_H
struct mail;
struct mailbox;
struct mail_namespace;
struct mail_search_arg;
struct fts_backend;
#include "seq-range-array.h"
enum fts_lookup_flags {
/* Specifies if the args should be ANDed or ORed together. */
/* Require exact matching for non-fuzzy search args by returning all
such matches as maybe_uids instead of definite_uids */
};
enum fts_backend_build_key_type {
/* Header */
/* MIME part header */
/* MIME body part */
/* Binary MIME body part, if backend supports binary data */
};
struct fts_backend_build_key {
/* for _KEY_HDR: */
const char *hdr_name;
/* for _KEY_BODY_PART and _KEY_BODY_PART_BINARY: */
const char *body_content_type;
/* Content-Disposition: header without parsing/validation if it exists,
otherwise NULL. */
const char *body_content_disposition;
};
struct fts_score_map {
float score;
};
struct fts_result {
/* The maybe_uids is useful with backends that can only filter out
messages, but can't definitively say if the search matched a
message. */
bool scores_sorted;
};
struct fts_multi_result {
/* box=NULL-terminated array of mailboxes and matching UIDs,
all allocated from the given pool. */
};
/* Get the last_uid for the mailbox. */
/* Returns TRUE if there exists an update context. */
/* Start an index update. */
struct fts_backend_update_context *
/* Finish an index update. Returns 0 if ok, -1 if some updates failed.
If updates failed, the index is in unspecified state. */
/* Switch to updating the specified mailbox. box may also be set to NULL to
make sure the previous mailbox won't tried to be accessed anymore. */
/* Expunge the specified mail. */
/* Switch to building index for specified key. If backend doesn't want to
index this key, it can return FALSE and caller will skip to next key. */
const struct fts_backend_build_key *key);
/* Make sure that if _build_more() is called, we'll assert-crash. */
/* Add more content to the index for the currently specified build key.
Non-BODY_PART_BINARY 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. This function may be called many times and the data
block sizes may be small. Backend returns 0 if ok, -1 if build should be
aborted. */
/* Refresh index to make sure we see latest changes from lookups.
Returns 0 if ok, -1 if error. */
/* Go through the entire index and make sure all mails are indexed,
and delete any extra mails in the index. */
/* Optimize the index. This can be a somewhat heavy operation. */
/* Returns TRUE if fts_backend_lookup() should even be tried for the
given args. */
const struct mail_search_arg *args);
/* Do a FTS lookup for the given search args. Backends can support different
kinds of search arguments, so match_always=TRUE must be set to all search
args that were actually used to produce the search results. The other args
are handled by the regular search code. The backends MUST ignore all args
that have subargs (SEARCH_OR, SEARCH_SUB), since they are looked up
separately.
The arrays in result must be initialized by caller. */
struct mail_search_arg *args,
enum fts_lookup_flags flags,
struct fts_result *result);
/* Search from multiple mailboxes. result->pool must be initialized. */
struct mail_search_arg *args,
enum fts_lookup_flags flags,
struct fts_multi_result *result);
/* Called after the lookups are done. The next lookup will be preceded by a
refresh. */
#endif