@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey) { return doQuery(new QuerySpec().withHashKey(hashKey)); }
@Override public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKey) { return doQuery(new QuerySpec() .withHashKey(new KeyAttribute(hashKeyName, hashKey))); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition)); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, QueryFilter... queryFilters) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition) .withQueryFilters(queryFilters)); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String filterExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition) .withFilterExpression(filterExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String filterExpression, String projectionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition) .withFilterExpression(filterExpression) .withProjectionExpression(projectionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
QuerySpec querySpec = new QuerySpec() .withHashKey("cityName", "Rockingham") .withProjectionExpression("Id, mainName, floatVariable, road"); ItemCollection<QueryOutcome> items = table.query(querySpec);
Table table = dynamoDB.getTable(tableName); Map<String, Object> expressionAttributeValues = new HashMap<String, Object>(); expressionAttributeValues.put(":x", "vl49uga5ljjcoln65rcaspmg8u"); QuerySpec spec = new QuerySpec() .withHashKey("id", "25g77vmummpr4mc5mb9vq36q43") .withFilterExpression("data.byUserId = :x") .withValueMap(expressionAttributeValues); ItemCollection<QueryOutcome> items = table.query(spec); Iterator<Item> iterator = items.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next().toJSONPretty()); }
Table table = dynamoDB.getTable(tableName); Map<String, Object> expressionAttributeValues = new HashMap<String, Object>(); expressionAttributeValues.put(":x", "vl49uga5ljjcoln65rcaspmg8u"); QuerySpec spec = new QuerySpec() .withHashKey("HashKeyAttribute", "HashKeyAttributeValue") .withFilterExpression("data.byUserId = :x") .withValueMap(expressionAttributeValues); ItemCollection<QueryOutcome> items = table.query(spec); Iterator<Item> iterator = items.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next().toJSONPretty()); }
Table table = dynamoDB.getTable("Movies"); QuerySpec querySpec = new QuerySpec(); querySpec.withKeyConditionExpression("yearkey = :yearval") .withValueMap( new ValueMap().withNumber(":yearval", yearkey)) .withScanIndexForward(false); IteratorSupport<Item, QueryOutcome> iterator = table.query(querySpec).iterator(); while (iterator.hasNext()) { Item movieItem = iterator.next(); System.out.println("Movie data ====================>" + movieItem.toJSONPretty()); moviesJsonList.add(movieItem.toJSON()); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey) { return doQuery(new QuerySpec().withHashKey(hashKey)); }
QuerySpec querySpec = new QuerySpec(); querySpec.withKeyConditionExpression("yearkey = :yearval and title = :title") .withFilterExpression("contains (subscriptions, :subscriptions)") .withValueMap( new ValueMap().withNumber(":yearval", yearKey) .withString(":title", title) .withString(":subscriptions", subscriptions));
List<String> queryResultJson = new ArrayList<>(); DynamoDB dynamoDB = new DynamoDB(dynamoDBClient); Table table = dynamoDB.getTable("table_name"); Index index = table.getIndex("indexname"); ItemCollection<QueryOutcome> items = null; QuerySpec querySpec = new QuerySpec(); querySpec.withKeyConditionExpression("firstname = :val1") .withValueMap(new ValueMap() .withString(":val1", fname)); items = index.query(querySpec); Iterator<Item> itemIterator = items.iterator(); while (itemIterator.hasNext()) { queryResultJson.add(itemIterator.next().toJSON()); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition)); }
@Override public ItemCollection<QueryOutcome> query(String hashKeyName, Object hashKey) { return doQuery(new QuerySpec() .withHashKey(new KeyAttribute(hashKeyName, hashKey))); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, QueryFilter... queryFilters) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition) .withQueryFilters(queryFilters)); }
Table table = dynamoDB.getTable("tableName"); Index index = table.getIndex("count-index"); ItemCollection<QueryOutcome> items = null; QuerySpec querySpec = new QuerySpec(); querySpec.withKeyConditionExpression("count= :v_count > 0 ") .withValueMap(new ValueMap() .withString(":v_count","1"); items = index.query(querySpec); while (iterator.hasNext()) { //....... }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String filterExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition) .withFilterExpression(filterExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition, String filterExpression, String projectionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doQuery(new QuerySpec().withHashKey(hashKey) .withRangeKeyCondition(rangeKeyCondition) .withFilterExpression(filterExpression) .withProjectionExpression(projectionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
private static PageIterable<Item, QueryOutcome> queryGSI(String appid, Pager p) { Pager pager = (p != null) ? p : new Pager(); Index index = getSharedIndex(); QuerySpec spec = new QuerySpec(). withMaxPageSize(pager.getLimit()). withMaxResultSize(pager.getLimit()). withKeyConditionExpression(Config._APPID + " = :aid"). withValueMap(new ValueMap().withString(":aid", appid)); if (!StringUtils.isBlank(pager.getLastKey())) { spec = spec.withExclusiveStartKey(new KeyAttribute(Config._APPID, appid), // HASH/PARTITION KEY new KeyAttribute(Config._ID, pager.getLastKey()), // RANGE/SORT KEY new KeyAttribute(Config._KEY, getKeyForAppid(pager.getLastKey(), appid))); // TABLE PRIMARY KEY } return index != null ? index.query(spec).pages() : null; }