Database Reference
In-Depth Information
Along with these two primary key conditions, several other add-ons are available for con-
figuring the query. Let me name these one by one:
• Usage of the exclusive start key
• Usage of the query or scan filter
• Usage of limit
• Usage of Select to retrieve only specified parameters using the Attrib-
utesToGet list
• Usage of consistency
• Usage of index and scanning direction
We will discuss each of these in detail. The first four configurations are common to both
query and scan operations, and the next two configurations are available only for query.
Let's first see how these could be added to the QueryRequest instance. Then we will
discuss detailed configurations. Have a look at the following code:
QueryRequest queryRequest = new QueryRequest()
.withTableName("Tbl_Book")
.withKeyConditions(keyConditions)
.withIndexName("Index_Name")
.withScanIndexForward(true)
.withSelect(Select.SPECIFIC_ATTRIBUTES)
.withAttributesToGet(Arrays.asList("BookTitle",
"PubDate"))
.withLimit(10)
.withConsistentRead(true);
We are already familiar with the first two ( with ) methods, which configure the table
name and key conditions to the QueryRequest instance. The third parameter specifies
the index through which the query has to be executed. The fourth parameter specifies
whether the search (or query operation) on index should be retrieved in the ascending or-
der; true means ascending order, false means descending order. By default, the order-
ing is ascending.
The fifth parameter is used to tell QueryRequest , which are all the attributes that need
to be retrieved from the table. Select is an enumerator just like ComparisonOper-
ator , whose possible values are shown as follows:
ALL_ATTRIBUTES : This returns all the item attributes from the table or index.
Search WWH ::




Custom Search