如何执行纯AQL查询?

huangapple go评论110阅读模式
英文:

How to execute pure aql query?

问题

我正在使用官方的Aerospike包来进行Golang开发。

有没有办法获取所有现有索引的列表?

aql> show indexes

另外,我还没有找到执行纯AQL查询的方法。

我该如何做到这一点?

更新:
我正在寻找类似于Rails中的这个例子,但是针对Aerospike的解决方案:

custom_query := "select * from users"
result, err := aerospikeClient.Query(nil, aerospike.NewStatement("namespace", "set", custom_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)

答案1

得分: 2

aql>show indexes 是一个有效的aql命令,应该显示服务器上当前存在的所有二级索引。

aql在底层运行C API。你可以在基本级别上使用aql做几乎所有的事情。
输入:aql>help,它会列出所有的aql命令,你可以复制粘贴!
aql还会将命令历史记录存储在一个文本文件中,所以可以跨会话保留。
aql>run 'filepath/filename' 是一个方便的方法,可以将所有的aql命令存储在一个文本文件中并运行它们。

关于aql查询--查看:select * from ns.<set> where ...,你可以进行相等性和范围查询,前提是你已经预先构建了二级索引。

Aerospike 3.12+版本引入了谓词过滤-即复杂查询-我认为aql还没有更新来运行这些查询。

希望对你有帮助。

英文:

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.<set> 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.

答案2

得分: 1

AQL是一个管理员和数据浏览工具。它并不是Aerospike的SQL,因为Aerospike没有本地实现查询语言。相反,所有的Aerospike客户端都提供了API,可以进行直接的get、put、scan、query调用,这些调用是过程式的,不像SQL那样是声明式的(在SQL中,你声明你想要的结果,服务器会找出一个查询计划)。Piyush提到了谓词过滤API,它非常棒,可以让你在扫描和二级索引查询上创建复杂的查询。

针对你关于获取所有索引的问题,你应该使用info命令。Aerospike允许你通过info命令获取和设置配置参数,并获得各种指标、运行微基准测试等。这是你进行管理和监控所需的一切。

你可以通过独立的asinfo工具运行sindex,或者使用任何客户端提供的info命令来调用它。

asinfo -v "sindex"
英文:

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 &quot;sindex&quot;

huangapple
  • 本文由 发表于 2017年6月8日 09:04:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/44425067.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定