Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secondary Index Data Type #253

Open
king-ds opened this issue Jan 22, 2020 · 1 comment
Open

Secondary Index Data Type #253

king-ds opened this issue Jan 22, 2020 · 1 comment

Comments

@king-ds
Copy link

king-ds commented Jan 22, 2020

Hi guys, may I know if the secondary indexes support float data type. As mentioned from this previous issue #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)
@dwelch-spike
Copy link
Contributor

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants