indexing - 对象键上的 Arangodb 动态索引

标签 indexing arangodb aql

Arangodb 2.8b3

有一些属性“规范”的文档,里面可以有1-100个键,比如

document {
  ...
  specification: {
      key1: "value",
      ...
      key10: "value"
  }
}

通过specification.key快速查询任务

For Doc IN MyCollection FILTER Doc.specification['key1'] == "value" RETURN Doc

尝试使用以下字段创建哈希索引:“规范”、“规范.*”、规范[*]、规范[*].*

索引从未使用过,是否存在无需重组结构或 future 计划的解决方案?

最佳答案

不,我们目前没有任何聪明的想法如何处理这样的结构的索引。内存使用量也会增加,因为属性名称也必须出现在每个索引值的索引中。

我们将发布什么with 2.8 is the ability to use indices on array structures :

db.posts.ensureIndex({ type: "hash", fields: [ "tags[*]" ] });

包含以下文件:

{ tags: [ "foobar", "bar", "anotherTag" ] }

使用这样的 AQL 查询:

FOR doc IN posts
  FILTER 'foobar' IN doc.tags[*]
  RETURN doc

您还可以在数组下索引文档:

db.posts.ensureIndex({ type: "hash", fields: [ "tags[*].value" ] });
db.posts.insert({
  tags: [ { key: "key1", value: "foobar"},
          { key: "key2", value: "baz" },
          { key: "key3", value: "quux" }
        ] });

以下查询将使用数组索引:

FOR doc IN posts
  FILTER 'foobar' IN doc.tags[*].value
  RETURN doc

但是,星号只能用于数组访问 - 它不能替代对象中的键匹配。

关于indexing - 对象键上的 Arangodb 动态索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34686228/

相关文章:

java - 全文索引器(或缓存)如何工作?

aerospike - 如何使用 aql 对 Aerospike 中特定 bin 中的所有列表进行排序?

arangodb - 获取 AQL 中受影响的行/文档数

javascript - javascript中的动态索引设置

arrays - 无效操作 : index of type *int golang

database - 我如何获得 Arangodb 的两个距离?

docker - 无法从 Web 界面访问 ArangoDB 服务

visualization - ArangoDB 和 Gephi : Import data from ArangoDB into Gephi

arangodb - ArangoDB AQL 中 (n) 个数组的交集

sql - 如何知道何时使用索引以及使用哪种类型?