Searches and retrieves data from the Gigya Data Store using an SQL-like query.

Description

Searches and retrieves data from Gigya's Data Store (DS) using an SQL-like query. For security reasons this method is not available for client side SDKs, only for server side SDKs. SQL queries are converted into Gigya's proprietary query language. SQL injection attacks are not possible because queries are both created by the customer and then converted by Gigya.

A short delay is possible between the writing of account data to the data base and its availability in queries.

 

Notes:

  • Always prefer accessing data objects directly using their IDs (with ds.get) rather than using search, whenever possible. Accessing data objects directly using their OIDs is faster and optimal for run-time. 
  • After data is published to the DS, building the indexes is done asynchronously for performance reasons, and may take up to one second to complete.
  • Please note, when using a cursor, the number of results in a batch (limit) is not guaranteed.
  • When querying for large numbers of results (>500) it is Best Practice to use the openCursor and then the cursorId with the nextCursorId value rather than attempting to page through results using timestamps of the user records.

Parameters

RequiredNameTypeDescription
querystringA SQL-like query specifying the data to retrieve. Please refer to the Query language specification section above.
querySigstring

An HMAC_SHA1 signature proving that the search call is in fact coming from your client application, in order to prevent fraud. Follow the instructions in Constructing a Signature using the following base-string:  query  + "_" +  expTime . When using cursors, this parameter should only be sent with the initial request and omitted from subsequent requests.

This parameter is required only when calling the search method from client side (i.e., Mobile SDKs)

expTimestring

The GMT time when the querySig parameter should expire. The expected format is the Unix time format (i.e., the number of seconds since Jan. 1st 1970). Gigya checks the time when the search request is received. If the time succeeds expTime, the request is considered forged.

This parameter is required only when calling the search method from client side (i.e., Mobile SDKs)


openCursorBooleanWhen set to true, the search response will include, in addition to the first page, another field named nextCursorId, which is used to fetch the next batch of results. This parameter should only be used on the first request and later should be removed from the request. When openCursor is true, the Limit clause sets the number of results returned in the batch.
Note: You cannot use a cursor if you have a 'group by' or when using 'start'.
cursorIdstringThe cursor ID that contains the nextCursorId value received in the first search call. Note: You cannot pass both cursorId and query on the same request - cursorId brings the next page for the search for which it was opened. Also, the time between search requests using a cursorId must not exceed 5 minutes.
Note: Each request should contain a different cursorId obtained from the response of the previous request (not the first) using the nextCursorId field. The exception to this rule is when a request fails or when a particular result set needs to be resent; in this case, resend the same cursorID (as long as it has not expired) to receive its associated result set.
timeoutintegerThe timeout for the request (in milliseconds). Default value is 20000 (20 seconds). Maximum allowed value is 60000 (60 seconds).

<script>
var dsSearchCodeExampleParams = {
	"api":"ds.search",
	"langs":"nojs",
	"useUserKey":false,
	"containerId":"dsSearchCodeExampleContainer",
	"params": {
		"query":"A query"
	}
}
</script>
<div id="dsSearchCodeExampleContainer"></div>

 

Response Data

FieldTypeDescription
dataArrayAn array of data objects retrieved from the DS.
objectsCountintegerThe number of objects returned in the "data" array.
totalCountintegerThe total number of object that satisfy the query in the DB. This is useful for knowing how many objects are in the DB, when fetching limited amount using the "limit" parameter.
nextCursorIdstringUsed to fetch the next batch of results. This parameter is not returned on the last batch of results, its absence means that the result set is finished.

Response Example

{
        "results": [{
            "oid": "050",
            "lastUpdated": 1344151787611,
            "lastUpdatedTime": "2012-08-05T07:29:47Z",
            "created": 1344151532974,
            "createdTime": "2012-08-05T07:25:32Z",
            "data": {
                "FN": 7,
                "Fn": 7,
                "field1": 7,
                "field2": 7,
                "field3": 7,
                "field4": "7",
                "field5": "7",
                "field6": "7",
                "field7": "7",
                "field8": "7",
                "field10": "d1_0",
                "field11": "d1_0",
                "field12": "d1_0",
                "field13": "d1_0",
                "fn": 7
            }},
        {
            "oid": "1c675e20f7724c93b9ca82aa7b206b41",
            "lastUpdated": 1344172297960,
            "lastUpdatedTime": "2012-08-05T13:11:37Z",
            "created": 1344172297960,
            "createdTime": "2012-08-05T13:11:37Z",
            "data": {
                "BloodType": "A",
                "Dislikes": "Evil",
                "EyeColor": "Brown",
                "HairColor": "Brown",
                "Height": "179 cms",
                "Likes": "Justice",
                "Occupation": "QA",
                "Weight": "94.1 kgs"
            }},
        {
            "UID": "_gid_t6BWv8yeJG6QZyq7Wtav1Q==",
            "oid": "51b5d8e72c664520a27c7020ff2f1494",
            "lastUpdated": 1344414722808,
            "lastUpdatedTime": "2012-08-08T08:32:02Z",
            "created": 1344414722808,
            "createdTime": "2012-08-08T08:32:02Z",
            "data": {
                "BloodType": "A",
                "Dislikes": "Evil",
                "EyeColor": "Brown",
                "HairColor": "Brown",
                "Height": "179 cms",
                "Likes": "Justice",
                "Occupation": "QA",
                "Weight": "94.1 kgs"
            }},
        {
            "oid": "677cc8b3437b40959b9b1288add0a2ec",
            "lastUpdated": 1344172153286,
            "lastUpdatedTime": "2012-08-05T13:09:13Z",
            "created": 1344172153286,
            "createdTime": "2012-08-05T13:09:13Z",
            "data": {
                "BloodType": "A",
                "Dislikes": "Evil",
                "EyeColor": "Brown",
                "HairColor": "Brown",
                "Height": "179 cms",
                "Likes": "Justice",
                "Occupation": "QA",
                "Weight": "94.1 kgs"
            }},
        {
            "oid": "8b8972c3b3114db2a0acdfa2617693bf",
            "lastUpdated": 1344428184385,
            "lastUpdatedTime": "2012-08-08T12:16:24Z",
            "created": 1344428184385,
            "createdTime": "2012-08-08T12:16:24Z",
            "data": {
                "BloodType": "A",
                "Dislikes": "Evil",
                "EyeColor": "Brown",
                "HairColor": "Brown",
                "Height": "179 cms",
                "Likes": "Justice",
                "Occupation": "QA",
                "Weight": "94.1 kgs"
            }},    
        {
            "oid": "super1",
            "lastUpdated": 1344172332701,
            "lastUpdatedTime": "2012-08-05T13:12:12Z",
            "created": 1344172332701,
            "createdTime": "2012-08-05T13:12:12Z",
            "data": {
                "BloodType": "A",
                "Dislikes": "Evil",
                "EyeColor": "Brown",
                "HairColor": "Brown",
                "Height": "179 cms",
                "Likes": "Justice",
                "Occupation": "QA",
                "Weight": "94.1 kgs"
            }}],
        "objectsCount": 9,
        "totalCount": 9,
        "statusCode": 200,
        "errorCode": 0,
        "statusReason": "OK",
        "callId": "fb5e8b258afc4016ad454cc9fd1d64ec",
        "time": "2015-03-22T11:42:25.943Z"
    }

 

More Information

ds.search Examples

 

<script>
$(document).ready(function() {
    lssdk.tableFixer();
    //lssdk.ceg.run(dsSearchCodeExampleParams);
});
</script>