![]() |
Indexation | ![]() |
The purpose of the first extension of the basic database API is to permit searching for certain keywords in the database entries. The current implementation achieves this by maintaining a few additional tables with the list of entries in which given keywords occur. We also maintain a few additional prefix tables which allow us to search for uncompleted keywords (prefixes of up to six characters). For efficiency reasons, the indexation is done at a low level in C++ (see
src/src/Plugins/Database/db_index.cpp
and the TeXmacs database). All field values are indexed automatically, except for the values of the contributor attribute; values of name fields are in addition indexed as a whole for the purpose of name completion.
It should be noticed that the indexation mechanism only indexes alphanumerical keywords and normalizes all keywords to lowercase. Accented characters and characters in other (e.g. cyrillic) scripts are also “transliterated” into basic unaccented roman characters. For instance, we write “é” and “щ” as “e” and “shch”. As a consequence, a search for “poincare” will match “Poincaré”.
Former versions of the Scheme layer provided a macro with-indexing for selecting an indexation method; this macro no longer exists, since indexation is now always performed by the C++ database engine.
Two types of supplementary constraints are supported: (:match keywords) and (:prefix keywords) (with the synonyms :contains and :completes), where keywords is a string. The string is split into keywords (normalized as explained above). The first constraint only returns entries for which each of the keywords occurs in one of the indexed fields. In the second case, the last keyword may also occur as a prefix of a keyword in one of the indexed fields. The helper (prefix->queries s) returns the query ((:completes s)).
Get the list of all possible completions of a prefix into a keyword which has been indexed in the current database.
Get the list of all values of name fields in the current database which admit prefix as a prefix. Contrary to the other indexation routines, the completions are not necessarily alphanumerical keywords, and case matters. This routine is for instance useful for the tab-completion of names of bibliographic entries.