Bin type works per record and not across records


#1

An aerospike record has a data type associated with it.

Bin("size", Value.get("amod")); - string
Bin("size", Value.get(1)); - int

aql> select * from default where PK = 'key3'
[
  {
    "size": 1
  }
]

aql> select * from default where PK = 'key2'
[
   {
     "size": "amod"
   }
]

I was expecting some error when storing the bin ‘size’ with int as type for one key and string for another. But it works! So bin type works per record basis (this is another difference from the bin being as column of this no sql db). I totally understand the concept of being schema less. Just wanted to confirm this behavior and get more insight.


#2

from the docs - Applications must use bins consistently in order for query and aggregation to work correctly.

Please assume this question is answered - http://www.aerospike.com/docs/architecture/data-model.html.

Thanks


#3

Yes, it works because Aerospike is schema free. Nobody checks the type of the bins for any of the records. However, you need a secondary index on a bin in order to run a query on it. If you declare the index to be numeric the records that have that bin with a different data type will be ignored by that particular index. That’s really all that is meant in consistency.