Limit on the number of secondary indexes on Map keys

Hello, Looking at the documentation here, it seems that the maximum no of secondary indices on a namespace is 256.

Aerospike supports up to 256 secondary indexes per namespace

I have a case where a bin (of type Map, as converted from JSON) needs to be indexed (on map keys) and the number of keys across all records in the bin could be around 30K.


  1. is the index on the above bin considered as a single index or 30K indices (in which case, it is not supported, per documentation)?

  2. does the latest version of Aerospike EE (based Java client APIs) support execution of a single query which uses multiple secondary indices (multiple bins), as a part of where clause?

Please let me know.

Thank you!

PS - seeking a sooner response on this please.

The answer to your first question is the index on keys of a map is considered just one index irrespective of how many distinct keys across records there are.

As for the second question, there can be only one clause in a query predicate, or equivalently, a query uses only one index. However, you can include any number of clauses in a filter. For best performance, the most selective clause should be specified as the where clause of the query, and the remaining conditions should go in the filter (that is specified in the query policy).

Thank you very much @neelp for the quick response.

As a follow up, I wanted to check if all the data types with in a JSON can be indexed including String, Number and Boolean.

Please let me know.

A secondary index can be created on integer and string values. A boolean type is not supported, and even if it is converted to an integer, because of its low cardinality is not recommended for indexing.

Thank you @neelp for the response.

I wanted to be a bit more specific towards JSON.

Given that the index on a JSON based bin (map) is considered as a single index, would it support filters on a boolean field, which but is one field among many in the JSON?

Please let me know.

@Unni, an index is defined on a specific element of a JSON document, not on the entire JSON document. Please check out this blog post for how indexes on a JSON document work, and the associated notebook for code examples. Hope this helps.

@neelp, thank you for the response. Given that map is a CDT and a JSON can be represented as a map, I am assuming that if I have 500 distinct keys across the records (in a bin of type map) in the set, Aerospike would use only a single secondary index in this case. Please correct me if am wrong here.

Do let me know if there is a relation between the number of nodes in the Aerospike cluster and the number of secondary indexes supported by it, assuming there is only one namespace.

I see there is advanced indexing capabilities available in the recent Aerospike version(s), on JSON documents per document shared by you earlier. Just wanted to check if we have a limit of 256 secondary indices in this case as well…?

Please let me know.

Thank you!

Yes, there is only one index irrespective of the number of distinct keys across records. For the index to be effective, be sure that the keys have good selectivity. For example, not all keys are the same or almost the same across all records.

The number of nodes in a cluster has no bearing on the the maximum number of secondary indexes in a namespace (yes, it is currently 256 per namespace).

thank you very much @neelp!

This topic was automatically closed 84 days after the last reply. New replies are no longer allowed.