Secondary Index on Custom Java Object

I have two classes.

class  A {

    String aName;
    B b;

    public A(String aName, B b) {
        this.aName = aName;
        this.b = b;

    public String getaName() {
        return aName;

    public B getB() {
        return b;

class B {
    String bName;

    public B(String bName) {
        this.bName = bName;

    public String getbName() {
        return bName;

I am storing A as a set in Aerospike and A.aName is primary key. I want a secondary key on A.b. I have created index on A.b attribute and able to persist also. But search from the index is not returning anything. As per my understanding, Aerospike supports only three type of indexes: String, Numeric and Geo,. Is there any option for custom object.

Cross posted to Stack Overflow:

Are you storing it as a binary blob? What type is A.b ?

Yes, I am storing as object through Java client, which would be Blob i think.

Binary blobs can be anything, there’s definitely no way to index that. If there is a particular field in your class you can pull out and set as a separate bin with a string/long type then that would work…

Thanks @Albot, we did the same thing and it works also but wanted to know some other alternative.

This was also posted to Stack Overflow where @rbotzer provides a few ideas for modelling.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.