All Products
Search
Document Center

Create an index table

Last Updated: Jul 09, 2021

Ganos has built-in spatial indexes. This way, you need only to insert spatial data at the frontend and specify the index to be created. You do not need to worry about how key-value pairs are designed or built for ApsaraDB for Lindorm (Lindorm). Before you insert data into an index table, define the schema of the table.

Ganos supports four types of indexes to meet the requirements in different scenarios. You can create different types of indexes in Ganos or create only a specific type of indexes. For example, if you perform only surrounding object queries, you need only to create Z2 indexes.

ID indexes

ID indexes are suitable for scenarios in which feature IDs (FIDs) of spatial objects are used to query data. Each FID must be unique.

Z2 and XZ2 indexes

Z2 and XZ2 indexes are suitable for spatial data queries, such as geo-fence queries and surrounding object queries. Z2 indexes are created for point objects and XZ2 indexes are created for line and plane objects.

Z3 and XZ3 indexes

Z3 and XZ3 indexes are suitable for spatio-temporal data queries, for example, historical trajectory queries within a specific spatial range or temporal range. Z3 indexes are created for point objects and XZ3 indexes are created for line and plane objects.

XYZ indexes

XYZ indexes are three-dimensional indexes. The dimensions are longitude, latitude, and elevation information. XYZ indexes are created for point objects.

Attribute indexes

Attribute indexes are suitable for attribute queries.

Create an index

Perform the following steps to create an index:

  1. Use SimpleFeatureType to define a spatio-temporal schema.

    1. Specify the name of the schema. You can use the name as the alias of the table.

    2. Specify the content of the schema. The content contains the definitions of attributes, geometries, and dates.

    3. You can also configure the following custom information:

      1. Specify the compression algorithm.

      2. Specify whether to use the tiny well-known binary (TWKB) format.

      3. Create an index for a column.

  2. Create geometries based on the defined spatio-temporal schema.

Examples

You can use different types of indexes in Ganos or use only a specific type of index, as described in the preceding section. If you perform only surrounding object queries, you need only to create Z2 indexes. We recommend that you create all types of indexes to improve the overall performance of data queries. However, this increases storage usage. If you want to reduce the storage usage of indexes, create only specific types of indexes as needed. Ganos provides built-in hints. You can use hints to specify indexes when you define SimpleFeatureType. The following syntax is used:

//sft specifies SimpleFeatureType.
sft.getUserData().put("geomesa.indices.enabled", "{index_name}:{col1}:{col2}:...,{index_name}:{col}");
            
  • Valid values of index_name: id, attr, z2, z3, xz2, xz3, and xyz.

  • col specifies the columns that are defined in SimpleFeatureType.

  • You can create one or more indexes. Separate indexes with commas (,).

  • If you want to add multiple columns to an index, separate the index and column names with colons (:).

In the following example, two Z3 indexes and an attribute index are created. One Z3 index is created on the start and dtg columns, and the other Z3 index is created on the end and dtg columns. An attribute index is created on the name and dtg columns.

sft.getUserData().put("geomesa.indices.enabled", "z3:start:dtg,z3:end:dtg,attr:name:dtg");