Aerospike C Client Manual ——— query-secondary index management

Source: Internet
Author: User
Tags aerospike

Secondary index management

The Aerospike C client provides the ability to create and delete secondary indexes in the database.

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

The index management call is committed to any node in the Aerospike cluster and the information is automatically propagated to the remaining nodes.

The creation and deletion of secondary indexes is an "expensive" operation and should be performed as a management task rather than as an application run-time task. Aerospike provides many tools, such as AQL, to create, delete, manage, and monitor sub-indexes. The APIs described in this section are provided to build these tools and other tools.

Here's how to create a secondary index. Each operation specifies namespace, set, Bin, and a name, uniquely identifying the secondary index in the namespace.

    • aerospike_index_integer_create()-Create an index on the integer (integer) value bin.
    • aerospike_index_string_create()-Creates an index on a string (string) value bin.

The following code snippet is referenced from the sample directory " Examples/query_examples " .

Please read the section "Creating connections" to understand how to establish a connection to a cluster.

The following code creates an integer index on the bin with the name "Binx", the namespace name of the record being indexed is called "test", the set name is "Test-set", and the index is identified as "idx_ Binx ".

< Span style= "font-family: Microsoft Jas Black" >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 the use of the Nammespace and secondary index names.

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

original link: http://www.aerospike.com/docs/client/c/usage/query/sindex.html Translator: Crooked neck belly Q  

Aerospike C Client Manual ——— query-secondary index management

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.