MiniVend will automatically build index files for a fast binary search of an individual field. This type of search is useful for looking up the author of a book based on the beginning of their last name, a book title based on its beginning, or other analagous situations.
Such a search requires a dictionary ordered index with the field to be
searched contained in the first field and the database key (product code)
in the second field. If you specify the INDEX field
modifier MiniVend will build the index upon database import:
Database products products.txt TAB Database products INDEX title
If the title field is the fourth column in the products database table, a file products.txt.4
will be built, containing two tab-separated fields something like:
American Gothic 19-202 Mona Lisa 00-0011 Sunflowers 00-342 The Starry Night 00-343
Options can be appended to the field name after a colon (:) -- the most useful will be f, which does a case-insensitive sort. Careful, you must use the mv_dict_fold option to the search in that case.
Another option is c
, which stands for ``comma index''. If you want to index on comma-separated
sub-fields within a field, use the :c option:
Database products products.txt TAB Database products INDEX category:c
This can get slow for larger databases and fields. MiniVend will split the
field on a comma (stripping surrounding whitespace) and make index entries
for each one. This allows multiple categories in one field while retaining
the fast category search mechanism. It might also be useful for a keywords
field.
The fast binary search is described in greater detail below -- see THE SEARCH ENGINE.