简体   繁体   English

使用AWS在Dynamo DB中搜索

[英]Searching in Dynamo DB with AWS

I want to search in Dynamo DB on multiple columns without using partition key. 我想在不使用分区键的情况下在多列上搜索Dynamo DB。

I am trying to implement the use case as we have in mysql like we can search over any column with a column type value. 我正在尝试实现我们在mysql中的用例,就像我们可以搜索具有列类型值的任何列。 But, as i got to know that the same use case can't satisfied by Dynamo DB. 但是,正如我所知,Dynamo DB无法满足相同的用例。

IS there any way to achieve this in Dynamo DB. 有没有办法在Dynamo DB中实现这一目标。

Any help would be appreciated! 任何帮助,将不胜感激!

如果使用DynamoDB Stream和将表更新写入AWS ElasticSearch集群的AWS Lambda函数索引表的内容,则可以支持任意搜索。

As Per Example Given In AWS Document of Local Search Indexes - PHP Low Level API , 根据本地搜索索引的 AWS文档中给出的示例- PHP低级API

Valid comparisons for the sort key condition are as follows: 排序键条件的有效比较如下:

  • sortKeyName = :sortkeyval - true if the sort key value is equal to :sortkeyval. sortKeyName =:sortkeyval - 如果排序键值等于:sortkeyval,则为true。
  • sortKeyName < :sortkeyval - true if the sort key value is less than :sortkeyval. sortKeyName <:sortkeyval - 如果排序键值小于:sortkeyval,则为true。
  • sortKeyName <= :sortkeyval - true if the sort key value is less than or equal to :sortkeyval. sortKeyName <=:sortkeyval - 如果排序键值小于或等于:sortkeyval,则为true。
  • sortKeyName > :sortkeyval - true if the sort key value is greater than :sortkeyval. sortKeyName>:sortkeyval - 如果排序键值大于:sortkeyval,则为true。
  • sortKeyName >= :sortkeyval - true if the sort key value is greater than or equal to :sortkeyval. sortKeyName> =:sortkeyval - 如果排序键值大于或等于:sortkeyval,则为true。
  • sortKeyName BETWEEN :sortkeyval1 AND :sortkeyval2 - true if the sort key value is greater than or equal to :sortkeyval1, and less than or equal to :sortkeyval2. sortKeyName BETWEEN:sortkeyval1 AND:sortkeyval2 - 如果排序键值大于或等于:sortkeyval1且小于或等于:sortkeyval2,则为true。
  • begins_with ( sortKeyName, :sortkeyval ) - true if the sort key value begins with a particular operand. starts_with(sortKeyName,:sortkeyval) - 如果排序键值以特定操作数开头,则为true。 (You cannot use this function with a sort key that is of type Number.) (您不能将此函数与Number类型的排序键一起使用。)

Note that the function name begins_with is case-sensitive. 请注意 ,函数名称starts_with区分大小写。

So, only AND supported for ranges. 因此,只有AND支持范围。 There is no OR . 没有OR Also you could try using begins_with . 您也可以尝试使用starts_with

Your Scenario Can be converted to following Code : 您的方案可以转换为以下代码:

$tableName = "genericTable";
$response = $dynamodb->query([
    'TableName' => $tableName,
    'IndexName' => 'OrderCreationDateIndex',
    'KeyConditionExpression' => 'hashkey = :h_key and columnName = :value',
    'ExpressionAttributeValues' =>  [
        ':h_key' => ['S' => 'foo'],
        ':value' => ['S' => 'bar']
    ],
    'Select' => 'ALL_PROJECTED_ATTRIBUTES',
    'ScanIndexForward' => false,
    'ConsistentRead' => true,
    'Limit' => 5,
    'ReturnConsumedCapacity' => 'TOTAL'
]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM