[英]How to get filtered result by using Hash Index in ArangoDB?
My data: 我的资料:
{
"rootElement": {
"names": {
"name": [
"Haseb",
"Anil",
"Ajinkya",
{
"city": "mumbai",
"state": "maharashtra",
"job": {
"second": "bosch",
"first": "infosys"
}
}
]
},
"places": {
"place": {
"origin": "INDIA",
"current": "GERMANY"
}
}
}
}
I created a hash index on job
field with the API: 我使用API在job
字段上创建了哈希索引:
http://localhost:8529/_db/_api/index?collection=Metadata HTTP://本地主机:8529 / _db / _api /指数集合=元
{
"type": "hash",
"fields": [
"rootElement.names.name[*].jobs"
]
}
And I make the search query with the API: 然后使用API进行搜索查询:
http://localhost:8529/_db/_api/simple/by-example HTTP://本地主机:8529 / _db / _api /简单/按示例
{
"collection": "Metadata",
"example": {
"rootElement.names.name[*].jobs ": "bosch"
}
}
Ideally, only the document containing job : bosch
should be returned as a result. 理想情况下,仅应返回包含job : bosch
的文档。 But for me it gives all the documents in the array name[*]
. 但是对我来说,它给出了数组name[*]
中的所有文档。 Where I am doing mistake? 我在哪里做错了?
Array asterisk operators are not supported by simple queries. 简单查询不支持数组星号运算符。
You need to use AQL for this: 您需要为此使用AQL:
FOR elem IN Metadata FILTER elem.rootElement.names.name[*].jobs = "bosch" RETURN elem
You can also execute AQL via the REST interface - However you should rather try to let a driver do the heavy lifting for you. 您也可以通过REST接口执行AQL-但是,您应该尝试让驱动程序为您完成繁重的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.