version 11 (Modified)
SET INDEX (aField; index{; mode{; *}})
Parameter | Type | Description | |
aField | Field | Field for which to create or delete the index | |
index | Boolean | Integer | True=Create index, False=Delete index, or | |
Create an index of the type: -1=Keywords, | |||
0=by default, 1=B-Tree standard, 3=B-Tree cluster | |||
mode | Longint | Obsolete (parameter ignored) | |
* | Asynchronous indexing if * is passed |
Description
The SET INDEX accepts two syntaxes:
If you pass a Boolean in theindex parameter, the command creates or removes the index for the field you pass in aField.
If you pass an integer in the index parameter, the command creates an index of the type specified.
index = Boolean
To index the field, pass True in index. The command creates an index of the default type. If the index already exists, the call has no effect.
If you pass False in index, the command will delete all the non-composite indexes associated with the field. If the index does not exist, the call has no effect.
index = Integer
In this case, the command creates an index of the type specified for aField. You can pass one of the following constants, found in the "Index Type" theme:
Keywords Index (-1): Index of keywords which permits word-by-word indexing of field contents. This type of index can only be used with fields of the Text or Alpha type.
Default Index Type (0): In this case, 4D defines the index type (excluding keywords indexes) that is the most optimized according to the contents of the field.
Standard BTree Index (1): Standard B-Tree type index. This multi-purpose index type is used in previous versions of 4D.
Cluster BTree Index (3): B-Tree type index using clusters. This type of index is optimized when the index contains few keywords, i.e. when the same values occur frequently in the data.
SET INDEX will not index locked records; it will wait until the record becomes unlocked.
Starting with version 11, the mode parameter no longer serves any purpose and will be ignored if it is passed.
The optional * parameter indicates an asynchronous (simultaneous) indexing. Asynchronous indexing allows the execution of the calling method to continue immediately, whether or not indexing is completed. However, execution will halt at any command that requires the index.
Notes:
Indexes created by this command do not have names. They cannot be deleted by the DELETE INDEX command using the syntax based on the name.
This command cannot be used to create or delete composite indexes.
This command cannot be used to delete a keywords index created by the CREATE INDEX command.
Examples
1. The following example indexes the field [Customers]ID:
UNLOAD RECORD([Customers]) SET INDEX ([Customers]ID; True)
2. You want to index the [Customers]Name field with the fast mode:
SET INDEX ([Customers]Name; True;100)
3. Creation of a keywords index:
SET INDEX([Books]Summary;Keywords Index)
See Also
CREATE INDEX, DELETE INDEX, GET FIELD PROPERTIES, ORDER BY, QUERY.