Operate Indexes¶
You can create an index for a tag and/or an edge type. An index lets traversal start from vertices or edges with the same property and it can make a query more efficient. You can create two index types: Tag Index and Edge Type Index. With Studio, you can use the Console page or the Schema page to create, retrieve, and delete indexes. This article introduces how to use the Schema page to operate an index.
NOTE: You can create an index when a tag or an edge type is created. But an index can decrease the write speed during data import. We recommend that you import data firstly and then create and rebuild an index. For more information, see nGQL Manual.
Studio version¶
Studio of v1.2.0-beta or later versions supports this function. To update the version, run this command.
docker-compose pull && docker-compose up -d
Prerequisites¶
To operate an index on the Schema page of Studio, you must do a check of these:
- The version of Studio is v1.2.0-beta or later.
- Studio is connected to Nebula Graph.
- A graph space, tags, and edge types are created.
- Your account has the authority of GOD, ADMIN, or DBA.
Create an index¶
To create an index on the Schema page, follow these steps:
- In the toolbar, click the Schema tab.
- On the Graph Space List page, find a graph space, and then click its name or the button in the Operations column.
- In the Current Graph Space field, confirm the name of the graph space. If necessary, you can choose another name to change the graph space.
- Click the Index tab and then click the + Create button.
-
On the Create page, do these settings:
a. Index Type: Choose to create an index for a tag or for an edge type. In this example, Edge Type is chosen.
b. Name: Choose a tag name or an edge type name. In this example, action is chosen.
c. Index Name: Specify a name for the new index. In this example, action_index is used.
d. Indexed Properties: Click Add, and then, in the dialog box, choose a property. If necessary, repeat this step to choose more properties. You can drag the properties to sort them. In this example,
actionId
andlabel
are chosen.NOTE: The order of the indexed properties has an effect on the result of the
LOOKUP
statement. For more information, see nGQL Manual.When the settings are done, the Equivalent to the following nGQL statement panel shows the statement equivalent to the settings.
-
Confirm the settings and then click the + Create button.
When an index is created, the index list shows the new index.
View indexes¶
To view indexes on the Schema page, follow these steps:
- In the toolbar, click the Schema tab.
- In the graph space list, find a graph space, and then click its name or the button in the Operations column.
- In the Current Graph Space field, confirm the name of the graph space. If necessary, you can choose another name to change the graph space.
- Click the Index tab, in the upper left corner, choose an index type, Tag or Edge Type.
- In the list, find an index and click its row. All its details are shown in the expanded row.
Delete an index¶
To delete an index on Schema, follow these steps:
- In the toolbar, click the Schema tab.
- In the graph space list, find a graph space, and then click its name or the button in the Operations column.
- In the Current Graph Space field, confirm the name of the graph space. If necessary, you can choose another name to change the graph space.
- Click the Index tab, find an index and then the button in the Operations column.