ZenQL search
Log in to add to favouritesSearch for entries using a ZenQL query, along with paging specifiers, allows a search to be performed against indexed documents held in ElasticSearch. The ZenQL query language allows any required sub-query structure to be defined and a comprehensive selection of operators and functions enable individual field level evaluation.
Key concepts
- ZenQL overview
- Get a list of entries (ZenQL examples)
- ZenQL cheatsheet
Call the entries.search() method in our delivery client to get a paged list of entries for a given ZenQL statement
Call signatures
search(zenql: string, linkDepth?: number): Promise<PagedList<Entry>>
search(zenqlQuery: ZenqlQuery, linkDepth?: number): Promise<PagedList<Entry>>
Parameters
Name | Type | Description |
---|---|---|
zenql | string | A ZenQL string containing the search criteria for returning entries |
zenqlQuery | ZenqlQuery | A zenql query object containing the search criteria for returning entries |
linkDepth | number | Resolve all fields containing content links in returned entries to this depth |
Returns
A Promise that will resolve with a Paged List of Entry
Example
Get a list of published entries of a given content type API ID using a ZenQL statement
import { ZenqlQuery } from "contensis-delivery-api";
const query = new ZenqlQuery(
"sys.contentTypeId=<content-type-id> and sys.versionStatus=published"
);
const entryList = await client.entries.search(query);
for (const entry of entryList.items) {
console.log(entry.entryTitle);
}