在JSON对象的子字段上进行DynamoDB查询 [英] DynamoDB query on sub field of JSON Object

查看:128
本文介绍了在JSON对象的子字段上进行DynamoDB查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在dynamoDB表中搜索json对象的子字段?

Is it possible to search for a subfield of a json object in dynamoDB table?

我的表:

Item: "item name",  
Location: {...},  
ItemInformation :  
{  
   ItemName: "itemName",  
   ProductLine: {  
      Brand: "Razer",  
      ManufacturerSource: "Razer"  
}

最初在这个表中,ItemInformation将是一个键并搜索一个对象,我们将为项目信息构造json,然后使用json字符串作为键进行查询..现在我们需要实现按该对象的子字段搜索,每次可以包含不同的字段,即isDigital:true。

Originally in this table ItemInformation would be a key and searching for an object we would construct the json for the item information and then query with the json string as a key.. Now we need to implement searching by sub fields of that object, which can contain different fields each time, i.e. isDigital: "true".

我在问题中注意到:
DynamoDB高级扫描 - JAVA

答案似乎是否定的,我必须将这些字段分开。但我很好奇PHP库为什么以及如何在dynamoDB中查询JSON对象上的子字段。那么将列作为单独的字段存储然后在所有字段上添加索引真的没有更好的解决方案吗?

The answer would seem to be no and I would have to separate out the fields. But I am curious about why and how the PHP library can query for sub fields on a JSON object in dynamoDB. Is there really no better solution then to store the column as separate fields and then add an index on all fields?

推荐答案

看完之后通过文档,按照我原先的意图实现搜索字段是不可行的。问题是,虽然值是JSON,但它们存储为字符串文字,因此我必须进行重构以开始存储为JSON对象。另外,我无法添加列和索引,因为搜索可以在任意数量的字段上运行,并且不同的项可以具有不同的字段,即项可以具有Brand,BatteryInformation,Name。鉴于要求这些子字段中的任何一个都应该是可搜索的,最好在Cloud Search或ElasticSearch中执行此操作,我可以在其中索引和搜索对象列中的任意字段和值。

After looking through documentation it is not feasible to implement the search fields as I originally intended. The problem is that while the values are JSON they are stored as string literals so I have to do refactoring to start storing as JSON objects. Additionally I cannot add in columns and index because the search could operate on any number of fields and different items can have different fields, i.e. an Item can have Brand, BatteryInformation, Name. Given that the requirement is that any of these subfields should be searchable its better to do this in Cloud Search or ElasticSearch where I can index and search on arbitrary fields and values within a column of an object.

由于这是一个DynamoDB表,我将使用CloudSearch,因为它提供了更容易的索引选项和数据集成。

Since this is a DynamoDB table, I am going to use CloudSearch since it offers easier indexing option and integration for data.

这篇关于在JSON对象的子字段上进行DynamoDB查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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