---
title: Query examples
slug: cms-12/docs/query-examples
docTags: 
createdAt: 2026-08-10T15:56:01.000Z
---

In addition to providing great, near-real-time search, Optimizely Search & Navigation can solve other querying needs for which you previously used the built-in [FindPagesWithCriteria](docId:_o-Cg2yKfL0Lmy8MsirE0) method. The examples below illustrate common querying scenarios specific to Optimizely Content Management System (CMS). See [Search and filter](docId\:w_KTtUUK9YJZ6Ydmwcnxt) for more filtering examples.

## Filter by category

```csharp
int categoryId = 3; //Category to match
var pages = SearchClient.Instance.Search<PageData>()
  .Filter(x => x.Category.Match(categoryId))
  .GetContentResult();
```

## Filter by Author or ChangedBy

```csharp
var pages = SearchClient.Instance.Search<PageData>()
  .Filter(x => x.ChangedBy.Match("Zlatan"))
  .GetContentResult();
```

## Filter by publish date

The example below finds pages published in October 2026.

```csharp
var pages = SearchClient.Instance.Search<PageData>()
  .Filter(x => x.StartPublish.MatchMonth(20216, 10))
  .GetContentResult();
```

To find pages published before October 2026, use the query below.

```csharp
var pages = SearchClient.Instance.Search<PageData>()
  .Filter(x => x.StartPublish.Before(new DateTime(2026, 10, 1)))
  .GetContentResult();
```

## Filter by page type

When using typed content, the easiest way to filter by content type is to use the `SearchClient` method and specify the desired type in the type parameter. However, in that case, pages of page types inheriting from the specified type are also matched. In other situations, you may not know what type to filter until runtime. In either case, you can filter with  `IContent.ContentTypeID`.

```csharp
int contentTypeId = 42;

var pages = SearchClient.Instance.Search<IContent>()
  .Filter(x => x.ContentTypeID.Match(contentTypeId))
  .GetContentResult();
```

## Filter by Site ID

In an enterprise scenario with multiple sites, all sites use one index. To enable filtering by site ID, the return value of an `IContent` extension method, `SiteId`, is indexed. Use `SiteId` to filter for content from a specific site.

```csharp
var content = SearchClient.Instance.Search<IContent>()
  .Filter(x => x.SiteId().Match("MySiteId"))
  .GetContentResult();
```
