amazon web services - Dynamodb query error - Query key condition not supported -


i trying query dynamodb table feed_guid , status_id = 1. returns query key condition not supported error. please find table schema , query.

$result =$dynamodbclient->createtable(array(             'tablename' => 'feed',             'attributedefinitions' => array(                 array('attributename' => 'user_id', 'attributetype' => 's'),                 array('attributename' => 'feed_guid',    'attributetype' => 's'),                 array('attributename' => 'status_id',  'attributetype' => 'n'),             ),             'keyschema' => array(                 array('attributename' => 'feed_guid', 'keytype' => 'hash'),             ),              'globalsecondaryindexes' => array(                 array(                     'indexname' => 'statusindex',                     'provisionedthroughput' => array (                         'readcapacityunits' => 5,                         'writecapacityunits' => 5                     ),                     'keyschema' => array(                         array(                             'attributename' => 'status_id',                             'keytype' => 'hash'                         ),                     ),                     'projection' => array(                         'projectiontype' => 'all'                     )                 ),                  array(                     'indexname' => 'useridindex',                     'provisionedthroughput' => array (                         'readcapacityunits' => 5,                         'writecapacityunits' => 5                     ),                     'keyschema' => array(                         array(                             'attributename' => 'user_id',                             'keytype' => 'hash'                         ),                     ),                     'projection' => array(                         'projectiontype' => 'all'                     )                 )              ),             'provisionedthroughput' => array(                 'readcapacityunits'  => 10,                 'writecapacityunits' => 20             )         )); 

following query update table.

 $result = $dynamodbclient->query(array(             'tablename' => 'feed',             'keyconditionexpression' => 'feed_guid = :v_fid , status_id = :v_sid ',             'expressionattributevalues' =>  array(                 ':v_fid' => array('s' => '71a27f0547cd5456d9ee7c181b6cb2f8'),                 ':v_sid' => array('n' => 1)             ),             'consistentread' => false         )); 

as mentioned, attribute included in "keyconditionexpression" should hash key only, matching base table schema (in case 'feed_guid'). if want query on both 'feed_guid' , 'status_id', need create table hash , range key , specify 'status_id' range key.

global secondary indexes separate base table, in case can query indexes separately (use 'status_id' in key condition when querying statusindex , use 'user_id' in key condition when querying useridindex).

please find more details on querying global secondary indexes here


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -