Skip to main content

Outline

At a glance
  • Query Logic: Optimizely Graph replaces legacy collections with a GraphQL-native delivery model.
  • Core Mechanics: Mastery of where, orderBy, and facets is essential for high-performance search.
  • Scalability: Cursor-based pagination is mandatory for datasets exceeding 10,000 items.
  • Optimization: Shifting complexity to the delivery hub requires a focus on projection and caching.

Developing high-performance search experiences in Optimizely CMS 13 requires an implementation-level understanding of the GraphQL delivery engine. Optimizely Graph replaces legacy server-side collections with a service-oriented model that natively supports advanced filtering, complex sorting, large-scale pagination, and dynamic facets. Mastery of these four core behaviors allows for the construction of search interfaces that are both responsive and precise.

1. Advanced Filtering via the where Clause

Filtering in Optimizely Graph is achieved using the where argument. This implementation allows for the refinement of result sets based on specific property conditions, reducing payload size and improving execution speed at the delivery hub.

Implementation Logic:

The schema provides a variety of operators to support different data types. Common operators include eq (equality), in (list matching), and contains (substring matching).

query FilteredContent($category: String!, $tags: [String!]) { Content( where: { Category: { eq: $category }, Tags: { in: $tags }, _fullText: { contains: "Optimizely" } } ) { items { Title Url } } }
  • Case Sensitivity: By default, string matching via the contains operator is case-insensitive.
  • Logical Operations: Filters can be nested within and, or, and not blocks to handle complex business rules.

2. Precise Sorting and Ranking with orderBy

Ordering results involves more than simple alphanumeric sorting. Optimizely Graph supports ranking-based sorting alongside standard property-based ordering.

Implementation Logic:

The orderBy argument accepts property names or a specialized _ranking object.

  • Field-based Sorting: Standard ASC/DESC ordering on properties like StartPublish or Name.
  • Relevance (BM25): The RELEVANCE ranking algorithm sorts items based on their statistical match to the query terms.
  • Semantic Sorting: For AI-enhanced experiences, semantic ranking understands the "meaning" of terms, allowing for conceptual relevance.
# Example: Sorting by Relevance with a secondary descending date sort query SortedResults($searchTerm: String!) { Content( where: { _fullText: { contains: $searchTerm } }, orderBy: { _ranking: RELEVANCE, StartPublish: DESC } ) { items { Title } } }

3. High-Scale Pagination: Skip/Limit vs. Cursor

Managing large result sets is handled through two distinct pagination patterns. The choice between them depends on the intended user interface and the scale of the dataset.

Skip/Limit Pagination

Ideal for traditional numbered pagination. This approach is performant for datasets under 10,000 items.

  • limit: Defines the number of records per page.
  • skip: Defines the offset (e.g., Page 3 with 10 results requires skip: 20).

Cursor-based Pagination

Mandatory for "Infinite Scroll" behaviors or datasets exceeding 10,000 items. Cursors provide a pointer to a specific location in the index, ensuring performance remains stable.

# Cursor-based request query PaginatedContent($cursor: String) { Content(cursor: $cursor, limit: 20) { total cursor # Returns the pointer for the next request items { Title } } }

4. Dynamic Faceting (Aggregations)

Facets allow the application to summarize result categories without retrieving individual records. This is technical metadata attached to the query result that provides counts based on content attributes.

Implementation Logic:

Facets are requested in a dedicated facets block. Optimizely Graph supports String, Date, and Numeric facets.

query SearchWithFacets { Content(where: { _fullText: { contains: "Cloud" } }) { facets { Category { Name { name # The category title (e.g., "Product") count # number of items in this category } } } items { Title } } }

Technical Best Practices:

  • Nesting: For complex properties, implementers must use nested structures.
  • Filtering Facets: The filters parameter within a facet can limit the aggregation to a relevant subset of values.

Conclusion

Effective search implementations in CMS 13 rely on the orchestration of precise filtering, context-aware sorting, and scalable navigation. By utilizing the specialized GraphQL arguments for Where, OrderBy, Cursor, and Facets, developers can build data-driven experiences that maintain performance at enterprise scale. As architectural complexity moves toward the delivery hub, focus remains on query optimization—specifically projection over expansion and the strategic use of caching templates.