full_text_search.h

full_text_search.h defines an abstract interface for all different kinds of full test search providers. The following operations are defined:

Initialization
At the start of the service, the search provider may do some initialization like checking if needed database tables are already available and if not create them.
Add Text
If a new text is stored, it can be added to the search.
Search
For the search, it is assumed that the input in any search control is passed to the search provider, without any processing. Multiple search results may be returned as reference which was provided, when the text was added. An additional id for any search result is given, which may be used to request more results.

Content
class IFullTextSearch

class IFullTextSearch

The class IFullTextSearch is the interface of the search provider. It is returned by a provider specific create function, which is outside the scope of this specification. It provides public member functions for the individual operations.

class IFullTextSearch {
public:
    virtual ~IFullTextSearch() {}
    virtual class IFullTextSearchStart * Start(class UTask * user, class IDatabase * database, const char * reference) = 0;
    virtual class IFullTextSearchAdd * Add(class UTask * user, const char * text, ulong64 reference) = 0;
    virtual class IFullTextSearchExec * Exec(class UTask * user, const char * input, ulong64 more, const char * select, const char * join, unsigned count) = 0;
};

Start

The start function is used to start the initialization task. Any database tables needed by the search provider internally will be initialzed.

database
The database connection to be used.
reference
Reference to the objects being searched as SQL expression. Example: "BIGINT REFERENCES messages(id) ON DELETE CASCADE"

It returns a pointer to the class IFullTextSearchStart, which can be used in the TaskComplete and TaskFailed callbacks to identify the request to which these callbacks are related.

Add

Starts the task of adding text to the search.

text
The raw text, as stored by the object which can be searched. The text is assumed to be in the HTML format, so any text inside < and > and & and ; is ignored.
reference
The reference of the object to be found.

It returns a pointer to the class IFullTextSearchAdd, which can be used in the TaskComplete and TaskFailed callbacks to identify the request to which these callbacks are related.

Exec

Starts the execution of a search.

input
The search as the user has entered. The input is assumed to be in the HTML format, so any text inside < and > and & and ; is ignored.
more
Id of the last search result, so that a new search with the same input can be started for more results. If 0 is used, a new search is assumed, which is identical to using the maximum long64 value as more.
select
A SQL select clause which is used to select the returned values.
Example: "author.sip AS sip, author.dn AS dn"
join
A SQL JOIN clause, which joins the elements of the table which is searched to the index table of the full text search. This can be used to apply a filter to the elements.
Example: "JOIN objects author ON messages.author = author.id"

A class IFullTextSearchExec is returned. For each result a TaskProgress is called.

class IFullTextSearchExec : public ITask {
public:
    virtual ulong64 GetId() = 0;
    virtual void Next() = 0;

    virtual int GetInt(const char * columnName) = 0;
    virtual dword GetUInt(const char * columnName) = 0;
    virtual long64 GetLong64(const char * columnName) = 0;
    virtual ulong64 GetULong64(const char * columnName) = 0;
    virtual bool GetBool(const char * columnName) = 0;
    virtual double GetDouble(const char * columnName) = 0;
    virtual const char * GetString(const char * columnName) = 0;
    virtual const char * GetStringWithNull(const char * columnName) = 0;
    virtual size_t GetDataSize(const char * columnName) = 0;
    virtual const byte * GetDataValue(const char * columnName) = 0;
};
GetId
This function can be used to get the id of the current result. The last id received can be used as more argument to read more results.
Next
Get the next result.
GetInt, GetUInt, ...
Read the values from the joined tables from the dataset, as identfied by the select value.