aerospike-client-python icon indicating copy to clipboard operation
aerospike-client-python copied to clipboard

Secondary Index Data Type

Open king-ds opened this issue 5 years ago • 1 comments

Hi guys, may I know if the secondary indexes support float data type. As mentioned from this previous issue https://github.com/aerospike/aerospike-client-python/issues/252, creating a secondary index must specify the appropriate data type to the value.

I'm raising this since I'm dealing with float values. Here are the sample data from aerospikedb, image

As seen above, fare_amount have decimal values. I was thinking that this is the reason why my script is not printing any results.

Here is the code,

client = aerospike.client(config).connect()

def print_result(args):
    key, metadata, record = args
    print(record)

try:
    client.index_integer_create('test', 'demo', 'fare_amount', 'fare_amount_indexer')
except ex.IndexFoundError as e:
    print(e)

query = client.query('test', 'demo')
query.select('trip_distance', 'pickup', 'dropoff', 'passenger_count')
query.where(p.between('fare_amount', 5,100))
query.foreach(print_result)

king-ds avatar Jan 22 '20 09:01 king-ds

Hi @king-ds,

You are correct. Secondary indexes on floats aren't supported yet. The given code creates a secondary index on a bin "fare_amount" that holds integers. Fare_amount is actually a bin that holds floats, so when the query attempts to find records with a "fare_amount" value between two integers, it finds nothing.

There is an error with the code. p.between() requires 3 arguments, a bin name, min, and max values .

dwelch-spike avatar Jan 22 '20 23:01 dwelch-spike