4D v14.3

SET INDEX

Home

 
4D v14.3
SET INDEX

SET INDEX 


 

SET INDEX ( aField ; index {; mode} {; *} )  
aField  Field in Field for which to create or delete the index
index  Boolean, Integer in • 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 in Obsolete (parameter ignored)
in Asynchronous indexing if * is passed

Compatibility note: This command is kept only for compatibility reasons. We now recommend using the CREATE INDEX and DELETE INDEX commands to manage indexes through programming.

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 standard indexes (i.e., non-composite and non-keyword) that are 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:

Constant Type Value Comment
Cluster BTree Index Longint 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.
Default Index Type Longint 0 4D specifies the index type (excluding keywords indexes) that is the most optimized according to the contents of the field.
Keywords Index Longint -1 Permits word-by-word indexing of field contents. This type of index can only be used with fields of the Text or Alpha type.
Standard BTree Index Longint 1 Standard B-Tree type index. This multi-purpose index type is used in previous versions of 4D

Note: A B-Tree index associated with a Text type field stores the first 1024 characters of the field (maximum). Therefore in this context, searches for strings containing more than 1024 characters will fail.

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.

The following example indexes the field [Customers]ID:

 UNLOAD RECORD([Customers])
 SET INDEX([Customers]ID;True)

You want to index the [Customers]Name field in asynchronous mode:

 SET INDEX([Customers]Name;True;*)

Creation of a keywords index:

 SET INDEX([Books]Summary;Keywords Index)

 
PROPERTIES 

Product: 4D
Theme: Structure Access
Number: 344

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

CREATE INDEX
DELETE INDEX
GET FIELD PROPERTIES
ORDER BY
QUERY

 
ARTICLE USAGE

4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)

Parent of : SET INDEX ( 4D v12.4)