AerospikeC client manual --- query-secondary index management

Source: Internet
Author: User
Tags aerospike

AerospikeC client manual --- query-secondary index management
The Aerospike C client provides the ability to create and delete secondary indexes in the database.

Currently, secondary indexes can be created using a combination of namespace, set, and bin names. The bin value type used to create an index is integer or string ). If an index is defined on a bin containing an integer value and named "x", only records containing bin "x" and whose bin value is an integer are indexed. Other records that contain bin "x" but whose data is not an integer are not indexed.

The index management call is submitted to any node in the Aerospike cluster, and the information is automatically transmitted to the remaining node.

Secondary index creation and deletion are "expensive" operations and should be performed as management tasks rather than as application runtime tasks. Aerospike provides many tools, such as aql, to create, delete, manage, and monitor secondary indexes. The APIS described in this section are provided to build these tools and other tools.

The following describes how to create a secondary index. Each operation specifies the namespace, set, bin, and a name, which uniquely identifies the secondary index in the namespace.

Aerospike_index_integer_create ()-create an index on the bin of the integer value.

Aerospike_index_string_create ()-create an index on the bin of the string value.

The subsequent code snippets reference the sample directory examples/query_examples ].

The following code creates an integer index on the bin named "binX, the created index belongs to the namespace name "test", set Name "test-set", and index ID "idx_binX ".

as_error err;if (aerospike_index_integer_create(&as, &err, NULL, "test", "demoset",        "binX", "idx_binX") != AEROSPIKE_OK) {    LOG("aerospike_index_integer_create() returned %d - %s", err.code,            err.message);    return false;}

The operation to delete the secondary index is aerospike_index_remove (), which requires nammespace and the secondary index name.

as_error err;aerospike_index_remove(&as, &err, NULL, "test", "idx_binX");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.