Querying and Retrieving KiiObjects
The following two methods are available to retrieve data from Kii Cloud:
Retrieving a KiiObject by ID or URI
You can retrieve one KiiObject by specifying its ID or URI.
To retrieve a specific KiiObject, you need to save its ID or URI when the KiiObject is created. You can choose to specify the ID of a KiiObject on your mobile app when the KiiObject is created.
Querying KiiObjects with conditions
You can retrieve a bunch of KiiObjects that meet a condition by querying a specific bucket for KiiObjects.
You can also just count the number of KiiObjects that meet a condition without retrieving the queried KiiObjects.
When a KiiObject is saved on Kii Cloud, the data at the first level of the JSON document hierarchy are automatically indexed and become searchable. The data at the second and subsequent levels are saved but not indexed nor searchable.
Indexes are automatically created when a KiiObject is saved. You do not need to define type information in advance or take any actions to create indexes.
Even if a new query feature is added or the data format is changed after a service release, you can still query data using the indexes without re-registration fo data.
You can create a query by combining conditions including the following with AND, OR, and NOT clauses:
- Get KiiObjects that have a field value that satisfies a specified comparison condition (＝, ＜, ≦, ≧, or ＞).
- Get KiiObjects that have a string field value that starts with a specified string.
- Get KiiObjects that have a field value that is equal to one of specified values.
- Get KiiObjects that have a field value whose type is equal to a specified type.
- Get KiiObjects that have a geolocation that is within a specified rectangular or circular area.
In addition to the values added by your mobile app, you can use these values in the JSON document of a KiiObject for a query: the creation time and modification time of a KiiObject and the ID of the user who owns a KiiObject.
When you retrieve KiiObjects, you can specify the maximum number of KiiObjects to be retrieved at a time, the field for sorting query results, and the sort order of ascending or descending.
If a query returns many KiiObjects, you can use the pagination feature for dividing the query results into multiple pages.
The client can retrieve all the query results by going through each page. Use features such as page flip and unlimited scrolling in your mobile app for minimizing the time to display the query results.