嵌套字段索引 [英] Indexing on nested field

查看:105
本文介绍了嵌套字段索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用AWS Developer Console中的仪表板在嵌套字段上创建索引。例如。如果我有以下架构:

I'm trying to create an index on a nested field, using the Dashboard in AWS Developer Console. E.g. if I have the following schema:

{ 'id': 1,
  'nested': {
     'mode': 'mode1',
     'text': 'nice text' 
  }
}

我能够在 nested.mode 上创建索引,但是每当我再按索引查询时,都不会返回。这让我认为DynamoDB在字段名称 nested.mode 而不是 mode 字段上创建了索引c $ c>嵌套。任何提示重新。我可能做错了什么?

I was able to create the index on nested.mode, but whenever I then go to query by index, nothing ever comes back. It makes me think that DynamoDB created the index on a field name nested.mode instead of the mode field of nested. Any hints re. what I might be doing wrong?

推荐答案

您不能(当前)基于嵌套属性创建二级索引。从 使用DynamoDB中的二级索引改善数据访问文档(重点是我的文档):

You cannot (currently) create a secondary index off of a nested attribute. From the Improving Data Access with Secondary Indexes in DynamoDB documentation (emphasis mine):


对于每个二级索引,您必须指定以下内容:

For each secondary index, you must specify the following:

...


  • 索引的关键架构。 索引键架构中的每个属性都必须是String,Number或Binary类型的顶级属性。不允许嵌套属性和多值集。关键架构的其他要求取决于索引的类型:

  • The key schema for the index. Every attribute in the index key schema must be a top-level attribute of type String, Number, or Binary. Nested attributes and multi-valued sets are not allowed. Other requirements for the key schema depend on the type of index:

但是,您可以在任何顶级JSON元素上创建索引

这篇关于嵌套字段索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆