REBUILD INDEX¶
Danger
If data is updated or inserted before the index's creation, you must rebuild the indexes manually to make sure that the indexes contain the previously added data. If the index is created before any data insertion, there is no need to rebuild the index.
Danger
During the rebuilding, all queries skip the index and perform sequential scans. This means that the return results can be different because not all the data is indexed during rebuilding.
REBUILD {TAG | EDGE} INDEX [<index_name_list>]
<index_name_list>::=
[index_name [, index_name] ...]
Use REBUILD INDEX
to rebuild the created tag or edge type index. For details on how to create an index, see CREATE INDEX.
Multiple indexes are permitted in a single REBUILD
statement, separated by commas. When the index name is not specified, all tag or edge indexes are rebuilt.
After rebuilding is complete, you can use the SHOW {TAG | EDGE} INDEX STATUS
command to check if the index is successfully rebuilt. For details on index status, see SHOW INDEX STATUS.
Example¶
nebula> CREATE TAG person(name string, age int, gender string, email string);
Execution succeeded (Time spent: 10.051/11.397 ms)
nebula> CREATE TAG INDEX single_person_index ON person(name(10));
Execution succeeded (Time spent: 2.168/3.379 ms)
nebula> REBUILD TAG INDEX single_person_index;
+------------+
| New Job Id |
+------------+
| 66 |
+------------+
nebula> SHOW TAG INDEX STATUS;
Nebula Graph creates a job to rebuild the index. The job ID is displayed in the preceding return message. To check if the rebuilding process is complete, use the SHOW JOB <job_id>
statement. For more information, see SHOW JOB.
Legacy version compatibility¶
In Nebula Graph 2.x, the OFFLINE
options is no longer needed and not supported.