CRUD operations create, read, update and delete index rules.
IndexRule defines how to generate indices based on tags and the index type. IndexRule should bind to a subject(stream or measure) through an IndexRuleBinding to generate proper indices.
bydbctl
is the command line tool in examples.
Create operation adds a new index rule to the database's metadata registry repository. If the index rule does not currently exist, create operation will create the schema.
An index rule belongs to its subjects' group. We should create such a group if there is no such group.
The command supposes that the index rule will bind to streams. So it creates a CATALOG_STREAM
group here.
$ bydbctl group create -f - <<EOF metadata: name: sw_stream catalog: CATALOG_STREAM resource_opts: shard_num: 2 block_interval: unit: UNIT_HOUR num: 2 segment_interval: unit: UNIT_DAY num: 1 ttl: unit: UNIT_DAY num: 7 EOF
The group creates two shards to store indexRule data points. Every day, it would create a segment that will generate a block every 2 hours.
The data in this group will keep 7 days.
Then, the next command will create a new index rule:
$ bydbctl indexRule create -f - <<EOF metadata: name: trace_id group: sw_stream tags: - trace_id type: TYPE_TREE location: LOCATION_GLOBAL EOF
This YAML creates an index rule which uses the tag trace_id
to generate a TREE_TYPE
index which is located at GLOBAL
.
Get(Read) operation gets an index rule's schema.
$ bydbctl indexRule get -g sw_stream -n trace_id
Update operation updates an index rule's schema.
This example changes the type from TREE
to INVERTED
.
$ bydbctl indexRule update -f - <<EOF metadata: name: trace_id group: sw_stream tags: - trace_id type: TYPE_INVERTED location: LOCATION_GLOBAL EOF
Delete operation deletes an index rule's schema.
$ bydbctl indexRule delete -g sw_stream -n trace_id
List operation list all index rules' schema in a group.
$ bydbctl indexRule list -g sw_stream