如何在ArangoDB中使用哈希索引获得过滤结果?

时间:2016-02-14 15:11:53

标签: arangodb arangojs arangodb-php

我的数据:

{
  "rootElement": {
    "names": {
      "name": [
        "Haseb",
        "Anil",
        "Ajinkya",
        {
          "city": "mumbai",
          "state": "maharashtra",
          "job": {
            "second": "bosch",
            "first": "infosys"
          }
        }
      ]
    },
    "places": {
      "place": {
        "origin": "INDIA",
        "current": "GERMANY"
      }
    }
  }
}

我使用API​​在job字段上创建了哈希索引:
http://localhost:8529/_db/_api/index?collection=Metadata

{
  "type": "hash",
  "fields": [
    "rootElement.names.name[*].jobs"
  ]
}

我使用API​​进行搜索查询:
http://localhost:8529/_db/_api/simple/by-example

{
  "collection": "Metadata",
  "example": {
    "rootElement.names.name[*].jobs ": "bosch"
  }
}

理想情况下,只应返回包含job : bosch的文档。但对我来说,它提供了数组name[*]中的所有文档。我在哪里做错了?

1 个答案:

答案 0 :(得分:1)

简单查询不支持数组星号运算符。

您需要使用AQL:

FOR elem IN Metadata FILTER elem.rootElement.names.name[*].jobs = "bosch" RETURN elem

您也可以执行AQL via the REST interface - 但是您应该尝试让司机为您做繁重的工作。

相关问题