|INM V12 Database for Director||Windows, Macintosh||Searching and sorting||3.x Regular & Light|
It is possible to search through the text content in a V12 Database file by defining an index on a field. This will allow for quick sorting and searching of the first few characters of a field. In some applications – typically when fields contain extensive information – you need to search for words that appear anywhere in a field, very efficiently. This is where you need to define a full-text index [or full-index for short] on that specific field. A full-index is an index defined on every single word of a field.
Let's suppose that we are using the following database.
|Last Name||First Name||Publication Title|
|Jordan||Ann||Soups and Salads for Dummies|
|Brown||Charles||The Hunchback of the Empire State Building|
|Pintado||Jack||Bounds on Branching Programs|
|Van Damme||Lucie||Natural and Artificial Intelligence|
|Peppermint||Patty||Mastering Soups in 32767 Easy Lessons|
In this example, looking for the word "Soup" in the Publication Title field requires a full-index for optimal search performance. If no index is defined on the Publication Title field, the same result can be achieved, but with slower performance. If a regular index is defined on the Publication Title field, publications that start with the word "Soup" can be quickly located, but publications that contain that word require more time. Full-indexes apply only to fields of type "string", including those which contain styled text (see Field Types, International Support and Managing Styled Text in the V12 user manual).
For optimal full-text search efficiency, some level of control is required on the way it is performed. For example, indexing trivial words such as "and", "or", "the", etc. (or equivalent words that appear frequently in your application's language) is useless, as most records would contain one or more occurrences of those words. V12 allows for this control via the use of Stop Words (see Stop Words in the V12 user manual).
To configure a field as full-indexed, you have to specify it as such in the database structure. For instance, if we want the publication title to be indexed in the precedent database, the structure should be the following one:
PublicationTitle string full-indexed
Then you can do your search as in any other search, using the mSetCriteria and mSelect method as described in the V12 user manual. For a complete code sample, we recommend that you download the open source "TextSeeker" sample available at the end of this page.
Each index takes up disk space, so it is not recommended that all fields be indexed! Full-indexes require much more space than regular indexes. Indexed fields should be limited to those likely to be searched and sorted most often.
Download Text Seeker Sample (supported on Director 6.5 and later):