orchardcore-sql-indexing
/orchardcore-sql-indexing
Skill for using SQL-based content indexing in Orchard Core. Covers content item indexing tables, field indexing tables, database schema reference, the ContentItemIndex SQL indexes including IDX_ContentItemIndex_ContentItemId, querying indexed data with C#, Razor views, Liquid templates, saved SQL queries and GraphQL, and SQL indexing performance patterns. Use this skill when requests mention Orchard Core SQL Indexing, Query SQL-Indexed Content, Enabling SQL Field Indexing, ContentItemIndex Schema, LocalizedContentItemIndex Schema, Content Field Index Tables, or closely related Orchard Core imp
- Author
- crestapps ↗
- Repository
- crestapps.agentskills ↗
- Licence
- MIT
- Last repository change
- 21.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Skill for using SQL-based content indexing in Orchard Core. Covers content item indexing tables, field indexing tables, database schema reference, the ContentItemIndex SQL indexes including IDX_ContentItemIndex_ContentItemId, querying indexed data with C#, Razor views, Liquid templates, saved SQL queries and GraphQL, and SQL indexing performance patterns. Use this skill when requests mention Orchard Core SQL Indexing, Query SQL-Indexed Content, Enabling SQL Field Indexing, ContentItemIndex Schema, LocalizedContentItemIndex Schema, Content Field Index Tables, or closely related Orchard Core imp
Original author description
Skill for using SQL-based content indexing in Orchard Core. Covers content item indexing tables, field indexing tables, database schema reference, the ContentItemIndex SQL indexes including IDX_ContentItemIndex_ContentItemId, querying indexed data with C#, Razor views, Liquid templates, saved SQL queries and GraphQL, and SQL indexing performance patterns. Use this skill when requests mention Orchard Core SQL Indexing, Query SQL-Indexed Content, Enabling SQL Field Indexing, ContentItemIndex Schema, LocalizedContentItemIndex Schema, Content Field Index Tables, or closely related Orchard Core imp
How it works
- Query SQL-Indexed Content
SKILL.md preview
---
name: orchardcore-sql-indexing
description: Skill for using SQL-based content indexing in Orchard Core. Covers content item indexing tables, field indexing tables, database schema reference, the ContentItemIndex SQL indexes including IDX_ContentItemIndex_ContentItemId, querying indexed data with C#, Razor views, Liquid templates, saved SQL queries and GraphQL, and SQL indexing performance patterns. Use this skill when requests mention Orchard Core SQL Indexing, Query SQL-Indexed Content, Enabling SQL Field Indexing, ContentItemIndex Schema, LocalizedContentItemIndex Schema, Content Field Index Tables, or closely related Orchard Core implementation, setup, extension, or troubleshooting work. Strong matches include work with OrchardCore.ContentFields.Indexing.SQL, OrchardCore.ContentManagement, ContentItemIndex, ISession, LocalizedContentItemIndex, ContentPart, ContentField, BooleanFieldIndex, TextFieldIndex, NumericFieldIndex, ContentPickerFieldIndex.
license: Apache-2.0
metadata:
author: CrestApps Team
version: "1.0"
---
# Orchard Core SQL Indexing - Prompt Templates
## Query SQL-Indexed Content
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.
### Guidelines
- The `ContentItemIndex` table is always available and indexes core content item fields.
- Enable `OrchardCore.ContentFields.Indexing.SQL` to create SQL index tables for content fields (Boolean, Text, Numeric, Date, etc.).
- Use `ISession.Query<ContentItem, TIndex>()` in C# to query indexed data.
- Use `@inject ISession Session` in Razor views to access query capabilities.
- In Liquid, create a SQL Query in Orchard Core admin and use `Queries.QueryName | query` to retrieve records.
- Dates are stored as UTC — convert to local time when displaying.
- Column types listed are SQL Server types; SQLite has no length limits on text fields.
- GraphQL filters are automatically generated from SQL index tables when `OrchardCore.ContentFields.Indexing.SQL` is enabled.
- All recipe JSON must be wrapped in `{ "steps": [...] }`.
- All C# classes must use the `sealed` modifier, except View Models.
### Enabling SQL Field Indexing
```json
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.ContentFields.Indexing.SQL"
],
"disable": []
}
]
}
```
### ContentItemIndex Schema
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. |
SQL indexes on `ContentItemIndex`: `IDX_ContentItemIndex_DocumentId`, `IDX_ContentItemIndex_DocumentId_ContentType`, `IDX_ContentItemIndex_DocumentId_Owner`, `IDX_ContentItemIndex_DocumentId_Author`, `IDX_ContentItemIndex_DocumentId_DisplayText` and, since Orchard Core 4.0, `IDX_ContentItemIndex_ContentItemId` (`ContentItemId`, `DocumentId`, `Published`, `Latest`). The last one lets reads by content item id (`IContentManager.GetAsync()` for one item or a batch, or `WHERE ContentItemId = ...` in a saved query) seek instead of scanning on SQL Server. Existing tenants get it through a `ContentItemIndex` migration step during the upgrade.
### LocalizedContentItemIndex Schema
| 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. |
### Content Field Index Tables
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)` |
### Querying from C#
```csharp
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();
}
}
```
### Querying from Razor
```html
@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>
```
### Querying from Liquid
First, create a SQL Query in the Orchard Core admin (Queries section). Name it `AllCountries` and do **not** select "Return Documents":
```sql
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:
```liquid
{% 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`).
### GraphQL Usage
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`:
```graphql
product(where: {price: {amount_gt: 10}}) {
contentItemId
displayText
price {
amount
}
}
```
**Collapsed part** — when `PricePart` is collapsed:
```graphql
product(where: {amount_gt: 10}) {
contentItemId
displayText
amount
}
```
**Collapsed with field name collision prevention:**
```graphql
product(where: {priceAmount_gt: 10}) {
contentItemId
displayText
priceAmount
}
```
Versions
The database has no other skills named orchardcore-sql-indexing.
Identical content appears in 1 other GitHub folders. We show one copy with the highest score.
Database snapshot: 13.11.2026 · package version 3c2852b5e5ad (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100orchardcore-query-indexing
Works with OrchardCore queries and indexing — SQL/Lucene/Elasticsearch queries, full-text index profiles, content part/field index handlers, and search. Use when the user needs to define a query, index content for search, write an index handler, register an indexing source, or… - 95orchardcore-content-queries
Skill for querying content items in Orchard Core using YesSql and saved queries. Covers ContentItemIndex queries and its indexes (including IDX_ContentItemIndex_ContentItemId), custom YesSql indexes, ISession and IContentManager queries, saved SQL queries of the Queries module… - 100orchardcore-search-indexing
Skill for configuring search and indexing in Orchard Core. Covers unified IndexProfile definitions, Lucene, Elasticsearch, and Azure AI Search providers, provider configuration sections under OrchardCore Search, document index handlers, index lifecycle recipes,… - 90msf-database
Use for SQL Server, T-SQL, EF Core, schema, stored procedures, indexing, query optimization or migration. Prefer engine-native verification. - 100data-sql-optimization
Optimize SQL query performance using EXPLAIN analysis, indexing strategies, and common anti-pattern fixes. Use this skill when the user needs to speed up slow queries, design indexes, fix N+1 problems, or optimize database performance — even if they say 'this query is slow',… - 100query-optimizer
Optimize SQL queries for performance with indexing strategies, query rewriting, and execution plan analysis. Use when queries are slow, optimizing database performance, or analyzing query execution.