INDEX statement
The INDEX statement creates a new index.
Syntax
INDEX [dbName] [indexType] field1, ..., fieldN;
Here field1, ..., fieldN is a non-empty list of fields. Each element of this list can be written either as a property stored in this table:
propertyId(param1, ..., paramN)
or as a typed parameter referring to the corresponding key field:
param
Description
The INDEX statement adds a new index by an ordered non-empty list of fields of one table. The list must contain at least one materialized property. The table that the index should be built for is determined by the first property in the list. All other properties in the list must be stored in the same table and use the same set of parameters. Typed parameters specified separately in the list correspond to the key fields of that table.
Parameters
-
dbNameString literal that specifies the physical index name in the database. If omitted, the name is generated automatically.
-
indexTypeOptional choice of a special index type. If omitted, a usual index is created.
-
LIKEFor string fields, keeps the usual index and additionally tries to create a specialized GIN index for
LIKEoperations. -
MATCHFor string fields, keeps the usual index and additionally tries to create specialized indexes for
MATCHandLIKE. The stringMATCHindex is built onto_tsvectorwith the current full-text search language.On a single field of type
TSVECTOR, creates only the specialized GIN index by that field itself.Specialized
LIKE/MATCHindexes for string fields are created only when the current DB adapter has the corresponding trigram/full-text support enabled. The usual index is created regardless of that support.
-
-
propertyIdThe ID of the property that should be stored in the table for which the index is being created.
-
param1, ..., paramNA list of property parameters. Each element of the list is a typed parameter.
Parameter names in
param1, ..., paramNmust be distinct. -
paramA typed parameter that determines the key field of the table.
Examples
INDEX customer(Order o);
number = DATA STRING (Order);
INDEX 'order_number_like' LIKE number(Order o);
searchVector = DATA TSVECTOR (Item);
INDEX 'item_search_match' MATCH searchVector(Item i);
date = DATA DATE (Order);
INDEX date(Order o), o;
INDEX supplier(Sku s, DATE d), s, price(s, d), d;