Important Note: Only documents created after May 30th 2023 are available for query and sort.
Examples
Here are some examples of what you can do with the Search Documents API. IMPORTANT: Query Template Documents - If you’re trying to query documents for a specific template can still follow the same guide below. Instead of retrieving a document in the Getting Started step, you simply need to use the Templates API route to retrieve the template. Retrieving theFile ID and FieldID for internal field queries work the same for both templates and documents because they both follow the same object structure.
Getting Started
Before we get started with querying documents data we are going to retrieve a document and grab our targetFileID and FieldID. These IDs will be used to query documents based on their internal field data.
Return exact match and sort results
Lookup documents that match the exact internal field value of"joy" and sort by createdOn.
Return substring match and sort results
Lookup documents that contain the internal field value of"joy" (case insensitive) and sort by internal field value.
Combine Multiple Filters
Lookup documents matching a combination of internal field data and date range. The documents below will contain the valuejoy and have a createdOn timestamp within the specified 6 day period.
Search query language
Search Syntax
| Type | Usage | Description | Examples |
|---|---|---|---|
| Exact Match | field:"value" | Exact match operator. | name:"joy" returns records where the name is exactly “joy” in a case-sensitive comparison. |
| Regular Expression Match | field:{$regex:"value", $options: "i"} | Substring and Case Insensitive match operator | name:{$regex: "joy", $options: "i"} returns records where the name contains “joy” in a case-insensitive comparison. Example matches are: “JOY”, “joY”, “joy@email.com”, etc. |
| Not Equal Match | field:{$ne:"value"} | Returns records that don’t match the clause | name:{$ne: "joy"} returns records that aren’t equal to “joy” |
| Greater Than / Less Than Match | field:{$gt:"value"}, field:{$gte:"value"}, field:{$lt:"value"}, field:{$lte:"value"} | Greater than/less than operators | createdOn:{$gt: 10} returns records that have a createdOn greater than 10. $gt specifies greater than. $gte specifies greater than or equal to. $lt specifies less than. $lte specifies less than or equal to. |
| AND | $and:[{field:"value1"}, {field:"value2"}] | The query returns only records that match both clauses. | $and:[{name: "joy"}, {template: "template_000"}] |
| OR | $or:[{field:"value1"}, {field:"value2"}] | The query returns records that match either of the clauses | $or:[{name: "joy"}, {template: "template_000"}] |
Sort query language
Sort Syntax
| Type | Usage | Description |
|---|---|---|
| Ascending Sort | field:1 | Returns records sorted in ascending order. |
| Descending Sort | field:-1 | Returns records sorted in descending order. |
Supported Query and Sort Fields
Query fields for documents
| Field | Description | Value Type |
|---|---|---|
template | Returns records that match a specified template identifier. | String |
group | Returns records that match a specified group identifier. | String |
stage | Returns records that match a specified stage. | String(‘draft’, ‘published’) |
name | Returns records that match a specified name | String |
createdOn | Returns records that match a specified createdOn date. | Number (millisecond timestamp) |
fields.FileID.FieldID.value | Returns records that match a specified field value. You will need to replace the FileID and FieldID with intended targets from your Joyfill Document or Template. | Mixed (String, Int, Float, or Boolean) |