Skip to content
Alsey Coleman Miller edited this page Mar 23, 2015 · 4 revisions

The Search API is the method for performing remote fetch requests. The URL for the Search API is

POST /search/entityName

Search Parameters

The POST request can attach a serialized JSON object to filter the results. A JSON body is optional, and all search parameters are optional. The JSON body encoding the Search Parameters uses the following schema:

{
    "Predicate" : <JSON object representing the search predicate.>,
    "FetchLimit" : <The search request's fetch limit. Value for this key will be an unsigned integer.>
    "FetchOffset" : <The offset for the search request. Value for this key will be an unsigned integer.>
    "IncludesSubentities" : <Whether the search request should include subentities. Value for this key will be a Boolean. Defaults to false (if omitted).>
    "SortDescriptors" : <The descriptors the search request should use to sort the results. Value for this key will an array of JSON dictionaries representing sort descriptors.>
}    

Search Sort Descriptors

The sort descriptors are encoded as an array of JSON objects representing an individual sort descriptor. Each sort descriptor JSON object has the property name as key, and ascending as value.

{
    "SortDescriptors" : [{"propertyName1" : true}, {"propertyName2" : false}, ...]
}

Search Predicate

The JSON object representing the search predicate supports compound predicates, allowing for very complex predicates. The JSON object encoding a predicate starts with a key defining the type of predicate and the predicate itself as the value.

Possible values:

Comparison
Compound

Schema:

{
    "Predicate" :
        {   
            "Comparison" : <Comparison predicate JSON object>
        }
}

Or:

{
    "Predicate" :
        {   
            "Compound" : <Compound predicate JSON object>
        }
}

Comparison Predicate

JSON Object uses the following schema:

{
    "Predicate" : 
        {
            "Comparison" :
            {
                "Key" : <Name of the property to perform the comparison against. Required.>,
                "Value" : <The JSON-compatible attribute or relationship value. Required.>,
                "Operator" : <Operator value. Required.>,
                "Modifier" : <Modifer value. Optional, defaults to Direct.>,
                "Options" : <Array of option values. Optional.>
            }
        }
}

Comparison Operators

Comparison operator values are strings.

<
<=
>
>=
=
!=
MATCHES
LIKE
BEGINSWITH
ENDSWITH
IN
CONTAINS
BETWEEN

Comparison Modifier

Comparison modifier values are strings.

DIRECT // Compare directly the left and right hand sides
ANY // Match with any entry in the destination of a to-many relationship
ALL // Compare all entries in the destination of a to-many relationship

Comparison Options

Comparison option values are strings.

[c] // Case Insensitive
[d] // Diacritic Insensitive
[n] // Normalized
[l] // Locale Sensitive

Compound Predicate

Compound predicate JSON objects consist of the type of compound predicate, and its subpredicates.

{
    "Predicate" : 
    {
        "Compound" : 
        {
            "PredicateType" : <Compound predicate type value>,
            "Subpredicates" : [ <Comparison Predicate JSON Object>, <Compound Predicate JSON Object>, ...]
        }
    }
}

Compound Predicate Type

Values are strings:

Not
And
Or

Response

If no error occurred, the server will return an HTTP status code of 200, and a JSON array representing the results.

[ {"EntityName1" : resourceID1}, {"EntityName2" : resourceID2 }, ... ]