Mike Bohoslavskyi
Mike Bohoslavskyi

Reputation: 35

How to execute pure aql query?

I'm using Official Aerospike Package for golang.

Is there any way to get list of all existing indexes this like?

aql> show indexes

Also I haven't found any way to execute pure aql query.

How can I do this?

Update: I'm looking for something similar to this but for aerospike (example from Rails) custom_query = "select * from users" result = ActiveRecord::Base.connection.execute(custom_query)

Upvotes: 1

Views: 1017

Answers (2)

Ronen Botzer
Ronen Botzer

Reputation: 7117

AQL is an admin and data browsing tool. It's not really Aerospike's SQL, as Aerospike doesn't natively implement a query language. Instead, all the Aerospike clients give you an API to make direct get, put, scan, query calls, and those are procedural, not declarative like SQL (where you state how you want the result and the server figures out a query plan). Piyush mentioned the predicate filtering API which is fantastic and lets you create complex queries over scans and secondary-index queries.

Specifically to your question about getting all the indexes, that's the type of thing you should use the info command for. Aerospike allows you to get and set config parameters through it, and get a wide range of metrics, run microbenchmark, etc. Everything you need for admin and monitoring.

You can run sindex through the standalone asinfo tool, or you can call it using the info command that any client provides.

asinfo -v "sindex"

Upvotes: 1

pgupta
pgupta

Reputation: 5415

aql>show indexes is a valid aql command and should show you all the secondary indexes you currently have on the server.

aql runs the C api underneath. You can do pretty much everything with aql at a rudimnetary level. Type: aql>help it will throw all the aql commands at you, cut and paste! aql also stores command history in a text file - so persists over sessions. aql>run 'filepath/filename' is a handy way to store all aql commands in a text file and run them.

Re: aql query -- look at: select * from ns. where ... you can do equality and range queries provided you have pre-built the secondary indexes.

Aerospike ver 3.12+ introduced predicate filtering - ie ~complex queries - I don't think aql has been updated to run those yet.

HTH.

Upvotes: 2

Related Questions