All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
Index Operations

Description

The Index API provides the ability to create and remove secondary indexes.

Aerospike currently supports indexing of strings and integers.

String Indexes

A string index allows for equality lookups. An equality lookup means that if you query for an indexed bin with value "abc", then only the records containing bins with "abc" will be returned.

To create a string index, see aerospike_index_string_create().

Integer Indexes

An integer index allows for either equality or range lookups. An equality lookup means that if you query for an indexed bin with value 123, then only the records containing bins with the value 123 will be returned. A range lookup means that you can query bins within a range. So, if your range is (1...100), then all records containing the a value in that range will be returned.

To create a integer index, see aerospike_index_integer_create().

+ Collaboration diagram for Index Operations:

Functions

as_status aerospike_index_integer_create (aerospike *as, as_error *err, const as_policy_info *policy, const as_namespace ns, const as_set set, const as_bin_name bin, const char *name)
 
as_status aerospike_index_remove (aerospike *as, as_error *err, const as_policy_info *policy, const as_namespace ns, const char *name)
 
as_status aerospike_index_string_create (aerospike *as, as_error *err, const as_policy_info *policy, const as_namespace ns, const as_set set, const as_bin_name bin, const char *name)
 

Function Documentation

as_status aerospike_index_integer_create ( aerospike as,
as_error err,
const as_policy_info policy,
const as_namespace  ns,
const as_set  set,
const as_bin_name  bin,
const char *  name 
)

Create a new secondary index on an integer bin.

if ( aerospike_index_integer_create(&as, &err, NULL, "test", "demo", "bin1", "idx_test_demo_bin1") != AEROSPIKE_OK ) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
nsThe namespace to be indexed.
setThe set to be indexed.
binThe bin to be indexed.
nameThe name of the index.
Returns
AEROSPIKE_OK if successful or index already exists. Otherwise an error.
as_status aerospike_index_remove ( aerospike as,
as_error err,
const as_policy_info policy,
const as_namespace  ns,
const char *  name 
)

Removes (drops) a secondary index.

if ( aerospike_index_remove(&as, &err, NULL, "test", idx_test_demo_bin1") != AEROSPIKE_OK ) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
nsThe namespace containing the index to be removed.
nameThe name of the index to be removed.
Returns
AEROSPIKE_OK if successful or index does not exist. Otherwise an error.
as_status aerospike_index_string_create ( aerospike as,
as_error err,
const as_policy_info policy,
const as_namespace  ns,
const as_set  set,
const as_bin_name  bin,
const char *  name 
)

Create a new secondary index on a string bin.

if ( aerospike_index_string_create(&as, &err, NULL, "test", "demo", "bin1", "idx_test_demo_bin1") != AEROSPIKE_OK ) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
nsThe namespace to be indexed.
setThe set to be indexed.
binThe bin to be indexed.
nameThe name of the index.
Returns
AEROSPIKE_OK if successful or index already exists. Otherwise an error.