Provides guidance on SQL-based content indexing in Orchard Core, covering index tables, querying with C#, Razor, Liquid, GraphQL, and performance patterns.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate code for querying SQL-indexed content in Orchard Core using YesSql sessions, Razor views, Liquid templates, and GraphQL.
ContentItemIndex table is always available and indexes core content item fields.OrchardCore.ContentFields.Indexing.SQL to create SQL index tables for content fields (Boolean, Text, Numeric, Date, etc.).ISession.Query<ContentItem, TIndex>() in C# to query indexed data.@inject ISession Session in Razor views to access query capabilities.Queries.QueryName | query to retrieve records.OrchardCore.ContentFields.Indexing.SQL is enabled.{ "steps": [...] }.sealed modifier, except View Models.{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.ContentFields.Indexing.SQL"
],
"disable": []
}
]
}
The ContentItemIndex table is always available for querying content items.
| Column | Type | Description |
|---|---|---|
Id | bigint | Primary key. |
DocumentId | bigint | YesSql document ID. |
ContentItemId | nvarchar(26) | Unique content item identifier. |
ContentItemVersionId | nvarchar(26) | Content item version identifier. |
Published | bit | Whether the item is published. |
Latest | bit | Whether this is the latest version. |
ContentType | nvarchar(255) | Content type name. |
ModifiedUtc | datetime | Last modified date (UTC). |
PublishedUtc | datetime | Publish date (UTC). |
CreatedUtc | datetime | Creation date (UTC). |
Owner | nvarchar(255) | Owner of the content item. |
Author | nvarchar(255) | Author of the content item. |
DisplayText | nvarchar(255) | Display text of the content item. |
In Orchard Core 4.0 the SQL indexes of ContentItemIndex are IDX_FK_ContentItemIndex (created by YesSql on DocumentId), IDX_ContentItemIndex_DocumentId_ContentType (DocumentId, ContentType, CreatedUtc, ModifiedUtc, PublishedUtc, Published, Latest), IDX_ContentItemIndex_ContentItemId (ContentItemId, DocumentId, Published, Latest), IDX_ContentItemIndex_ContentType (ContentType, DocumentId, Published, Latest), IDX_ContentItemIndex_Owner (Owner, DocumentId, Published, Latest) and IDX_ContentItemIndex_ContentItemVersionId (ContentItemVersionId, DocumentId), plus IDX_ContentItemIndex_ModifiedUtc (ModifiedUtc, DocumentId, Latest, Published, ContentType) and IDX_ContentItemIndex_ContentType_ModifiedUtc (ContentType, ModifiedUtc, DocumentId, Latest, Published), which let the content items admin list sorted by modified date stop at the end of the page. Filters on one content type (admin list and its count, GraphQL, pickers, sitemaps), on the owner, on a content item id, or on a version id (GetVersionAsync, loading Lucene or Elasticsearch results) now seek instead of scanning. The 3.x indexes IDX_ContentItemIndex_DocumentId, IDX_ContentItemIndex_DocumentId_Owner, IDX_ContentItemIndex_DocumentId_Author and IDX_ContentItemIndex_DocumentId_DisplayText are dropped. To filter on another column, such as Author or DisplayText, add your own index from a data migration with SchemaBuilder.AlterIndexTableAsync<ContentItemIndex>(). Existing tenants get these changes through migration steps (versions 8 and 9). On a large table they take a moment; with YesSql 6.3 they no longer block writes on SQL Server editions with online index operations and on MySQL (OrchardCore:YesSql:ConcurrentIndexCreationEnabled), but still do on PostgreSQL and SQLite.
ContentItemIndex and LocalizedContentItemIndex declare SingleRecordPerDocument() and ExclusiveToDocumentType(), so a query that only joins them isn't grouped by document and its count doesn't join Document. The content field index tables (TextFieldIndex, ContentPickerFieldIndex, ...) hold one row per field and don't declare them: joining one brings the grouping back.
| Column | Type | Description |
|---|---|---|
Id | bigint | Primary key. |
DocumentId | bigint | YesSql document ID. |
ContentItemId | nvarchar(26) | Unique content item identifier. |
Published | bit | Whether the item is published. |
Latest | bit | Whether this is the latest version. |
LocalizationSet | nvarchar | Localization set identifier. |
Culture | nvarchar | Culture code for the content item. |
Each field type has a corresponding index table. All share these common columns:
| Column | Type | Description |
|---|---|---|
Id | bigint | Primary key. |
DocumentId | bigint | YesSql document ID. |
ContentItemId | nvarchar(26) | Content item identifier. |
ContentItemVersionId | nvarchar(26) | Content item version identifier. |
ContentType | nvarchar(255) | Content type name. |
ContentPart | nvarchar(255) | Content part name. |
ContentField | nvarchar(255) | Content field name. |
Published | bit | Whether the item is published. |
Latest | bit | Whether this is the latest version. |
Field-specific columns by table:
| Table | Value Column(s) | Type |
|---|---|---|
BooleanFieldIndex | Boolean | bit |
ContentPickerFieldIndex | SelectedContentItemId | nvarchar(26) |
DateFieldIndex | Date | datetime |
DateTimeFieldIndex | DateTime | datetime |
HtmlFieldIndex | Html | nvarchar(max) |
LinkFieldIndex | Url, BigUrl, Text, BigText | nvarchar(766) / nvarchar(max) |
MultiTextFieldIndex | Value, BigValue | nvarchar(766) / nvarchar(max) |
NumericFieldIndex | Numeric | decimal(19,5) |
TextFieldIndex | Text, BigText | nvarchar(766) / nvarchar(max) |
TimeFieldIndex | Time | bigint (TimeSpan ticks) |
UserPickerFieldIndex | SelectedUserId | nvarchar(255) |
using OrchardCore.ContentManagement;
using OrchardCore.ContentFields.Indexing.SQL;
using YesSql;
namespace MyModule;
public sealed class ProductService
{
private readonly ISession _session;
public ProductService(ISession session)
{
_session = session;
}
public async Task<IEnumerable<ContentItem>> GetProductsByTextField(
string contentType,
string contentField)
{
return await _session
.Query<ContentItem, TextFieldIndex>(x =>
x.ContentType == contentType &&
x.ContentField == contentField &&
x.Published)
.ListAsync();
}
public async Task<IEnumerable<ContentItem>> GetExpensiveProducts(decimal minPrice)
{
return await _session
.Query<ContentItem, NumericFieldIndex>(x =>
x.ContentType == "Product" &&
x.ContentField == "Price" &&
x.Numeric > minPrice)
.ListAsync();
}
public async Task<IEnumerable<ContentItem>> GetRecentArticles(DateTime since)
{
return await _session
.Query<ContentItem, ContentItemIndex>(x =>
x.ContentType == "Article" &&
x.Published &&
x.CreatedUtc >= since)
.ListAsync();
}
}
@using OrchardCore.ContentManagement
@using OrchardCore.ContentFields.Indexing.SQL
@using YesSql
@inject ISession Session
@{
var contentItems = await Session
.Query<ContentItem, TextFieldIndex>(x =>
x.ContentType == "Acme" &&
x.ContentField == "Country")
.ListAsync();
}
<ul>
@foreach (var item in contentItems)
{
<li>@item.DisplayText</li>
}
</ul>
First, create a SQL Query in the Orchard Core admin (Queries section). Name it AllCountries and do not select "Return Documents":
SELECT * FROM TextFieldIndex
WHERE ContentType = 'Acme' AND ContentField = 'Country'
Saved SQL queries are parsed by the Cyqwel SQL parser (Orchard Core 4.0): only SELECT statements are accepted, the admin editor reports syntax errors with line and column when the query has no Liquid, and table names, LIMIT/OFFSET and helper functions (year(), month(), now(), random(), ...) are translated to the tenant database dialect. Use @name:default parameters for user input. See orchardcore-content-queries for the full Queries module reference.
Then use the query in a Liquid template:
{% assign allCountries = Queries.AllCountries | query %}
{% for country in allCountries %}
{{ country.Text }}
{% endfor %}
Saved queries are also exposed as data sets of the Queries data source, so data pipelines and reports can read them (see orchardcore-data-sources).
Enable OrchardCore.ContentFields.Indexing.SQL to build filters based on dynamic content fields in GraphQL queries.
Standard usage — filtering products by a NumericField named Amount on PricePart:
product(where: {price: {amount_gt: 10}}) {
contentItemId
displayText
price {
amount
}
}
Collapsed part — when PricePart is collapsed:
product(where: {amount_gt: 10}) {
contentItemId
displayText
amount
}
Collapsed with field name collision prevention:
product(where: {priceAmount_gt: 10}) {
contentItemId
displayText
priceAmount
}
What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-sql-indexingfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job