Secondary Index Creation

secondary
index

#1

Question:

How do I check if a secondary index already exists? AQL will show me all the indexes but in the Java client I don’t see how to do it. I see that I don’t get any exception if I make a call to recreate an index that already exists. In that case does it a NOOP on the server or are there any side effects like re-indexing?

Answer:

We recommend using SINDEX as a parameter of ASINFO for querying if a secondary index.

$ asinfo -v "sindex"

Please see the examples in the following link for a more detailed usage of SINDEX SINDEX Doc

In the Java client API, you can use either of the ‘request’ methods provided for the query. We recommend the following one for SINDEX for getting one info value by name from the specified database server node. Take a look at the following page.

http://www.aerospike.com/apidocs/java/com/aerospike/client/Info.html#request(com.aerospike.client.cluster.Node, java.lang.String)

When trying recreate the same index the the server returns error and does nothing. Java/C# clients will swallow this error and not throw exception. However, if it is exactly same bintype, set, namespace, it will do some network messaging and then NOOP.