Skip to main content

Search 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

Call the entries.search() method in our delivery client to get a paged list of entries for a given ZenQL statement

Call signatures

TypeScript
search(zenql: string, linkDepth?: number): Promise<PagedList<Entry>>

search(zenqlQuery: ZenqlQuery, linkDepth?: number): Promise<PagedList<Entry>>

Parameters

NameTypeDescription
zenqlstringA ZenQL string containing the search criteria for returning entries
zenqlQueryZenqlQueryA zenql query object containing the search criteria for returning entries
linkDepthnumberResolve 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

TypeScript
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);
}

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request