All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
aerospike_index.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2008-2013 by Aerospike.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  *****************************************************************************/
22 
23 /**
24  * @defgroup index_operations Index Operations
25  * @ingroup client_operations
26  *
27  * The Index API provides the ability to create and remove secondary indexes.
28  *
29  * Aerospike currently supports indexing of strings and integers.
30  *
31  * ## String Indexes
32  *
33  * A string index allows for equality lookups. An equality lookup means that
34  * if you query for an indexed bin with value "abc", then only the records
35  * containing bins with "abc" will be returned.
36  *
37  * To create a string index, see aerospike_index_string_create().
38  *
39  * ## Integer Indexes
40  *
41  * An integer index allows for either equality or range lookups. An equality
42  * lookup means that if you query for an indexed bin with value 123, then only
43  * the records containing bins with the value 123 will be returned. A range
44  * lookup means that you can query bins within a range. So, if your range is
45  * (1...100), then all records containing the a value in that range will
46  * be returned.
47  *
48  * To create a integer index, see aerospike_index_integer_create().
49  *
50  */
51 
52 #pragma once
53 
54 #include <aerospike/aerospike.h>
55 #include <aerospike/as_bin.h>
56 #include <aerospike/as_error.h>
57 #include <aerospike/as_key.h>
58 #include <aerospike/as_policy.h>
59 #include <aerospike/as_status.h>
60 
61 /******************************************************************************
62  * FUNCTIONS
63  *****************************************************************************/
64 
65 /**
66  * Create a new secondary index on an integer bin.
67  *
68  * ~~~~~~~~~~{.c}
69  * if ( aerospike_index_integer_create(&as, &err, NULL, "test", "demo", "bin1", "idx_test_demo_bin1") != AEROSPIKE_OK ) {
70  * fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
71  * }
72  * ~~~~~~~~~~
73  *
74  * @param as The aerospike instance to use for this operation.
75  * @param err The as_error to be populated if an error occurs.
76  * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
77  * @param ns The namespace to be indexed.
78  * @param set The set to be indexed.
79  * @param bin The bin to be indexed.
80  * @param name The name of the index.
81  *
82  * @return AEROSPIKE_OK if successful. AEROSPIKE_ERR_INDEX_FOUND if the index already exists. Otherwise an error.
83  *
84  * @ingroup index_operations
85  */
87  aerospike * as, as_error * err, const as_policy_info * policy,
88  const as_namespace ns, const as_set set, const as_bin_name bin, const char * name);
89 
90 /**
91  * Create a new secondary index on a string bin.
92  *
93  * ~~~~~~~~~~{.c}
94  * if ( aerospike_index_string_create(&as, &err, NULL, "test", "demo", "bin1", "idx_test_demo_bin1") != AEROSPIKE_OK ) {
95  * fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
96  * }
97  * ~~~~~~~~~~
98  *
99  * @param as The aerospike instance to use for this operation.
100  * @param err The as_error to be populated if an error occurs.
101  * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
102  * @param ns The namespace to be indexed.
103  * @param set The set to be indexed.
104  * @param bin The bin to be indexed.
105  * @param name The name of the index.
106  *
107  * @return AEROSPIKE_OK if successful. AEROSPIKE_ERR_INDEX_FOUND if the index already exists. Otherwise an error.
108  *
109  * @ingroup index_operations
110  */
112  aerospike * as, as_error * err, const as_policy_info * policy,
113  const as_namespace ns, const as_set set, const as_bin_name bin, const char * name);
114 
115 /**
116  * Removes (drops) a secondary index.
117  *
118  * ~~~~~~~~~~{.c}
119  * if ( aerospike_index_remove(&as, &err, NULL, "test", idx_test_demo_bin1") != AEROSPIKE_OK ) {
120  * fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
121  * }
122  * ~~~~~~~~~~
123  *
124  * @param as The aerospike instance to use for this operation.
125  * @param err The as_error to be populated if an error occurs.
126  * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
127  * @param ns The namespace containing the index to be removed.
128  * @param name The name of the index to be removed.
129  *
130  * @return AEROSPIKE_OK if successful. Otherwise an error.
131  *
132  * @ingroup index_operations
133  */
135  aerospike * as, as_error * err, const as_policy_info * policy,
136  const as_namespace ns, const char * name);
137 
138 
139 /**
140  * @}
141  */
as_namespace ns
Definition: as_scan.h:333
as_status
Definition: as_status.h:32
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)
as_status aerospike_index_remove(aerospike *as, as_error *err, const as_policy_info *policy, const as_namespace ns, const char *name)
char as_namespace[AS_NAMESPACE_MAX_SIZE]
Definition: as_key.h:66
char as_bin_name[AS_BIN_NAME_MAX_SIZE]
Definition: as_bin.h:53
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)
char as_set[AS_SET_MAX_SIZE]
Definition: as_key.h:73