<< All versions

Skill v1.0.0

currentAutomated scan100/100
crestapps/crestapps.agentskills/orchardcore-lucene
──Details
PublishedNovember 23, 2026 at 04:33 AM
Content Hashsha256:6274a73c98187ea3...
Git SHA7aed9dd90485
──Files
Files (1 file, 11.9 KB)
SKILL.md11.9 KBactive
SKILL.md · 369 lines · 11.9 KB

name: orchardcore-lucene description: Skill for configuring Lucene search in Orchard Core. Covers Lucene index creation and management, recipe steps for index operations, Lucene queries and the Lucene Query API, query filters, the Lucene Worker background task, custom data indexing, automatic field mapping, Elasticsearch Query DSL support in Lucene, LuceneSearchPermissions and dynamic per-index permissions, and the Orchard Core 4.0 removal of obsolete Lucene permission members. Use this skill when requests mention Orchard Core Lucene Search, Configure Lucene Search, Enabling Lucene Features, Creating a Lucene Index Profile, Legacy Index Creation (Obsolete), Reset Lucene Index, Rebuild Lucene Index, or closely related Orchard Core implementation, setup, extension, or troubleshooting work. Strong matches include work with OrchardCore.Lucene, OrchardCore.Search.Lucene.Worker, OrchardCore.Search, OrchardCore.Indexing, CreateOrUpdateIndexProfile, LuceneIndexSettings, ManageLuceneIndexes, QueryLuceneApi. license: Apache-2.0 metadata: author: CrestApps Team version: "1.0"


Orchard Core Lucene Search - Prompt Templates

Configure Lucene Search

You are an Orchard Core expert. Generate code and configuration for Lucene-based full-text search in Orchard Core.

Guidelines

  • Enable OrchardCore.Lucene to manage Lucene indexes.
  • Lucene indexes are stored on the local file system under /App_Data/Sites/{TenantName}/Lucene/{IndexName}.
  • Use the CreateOrUpdateIndexProfile recipe step to create indexes (preferred over the obsolete lucene-index and LuceneIndexSettings steps).
  • Use the ResetIndex recipe step to restart indexing from the beginning without deleting existing entries (preferred over the obsolete lucene-index-reset step).
  • Use the RebuildIndex recipe step to delete and recreate the full index (preferred over the obsolete lucene-index-rebuild step).
  • Lucene queries use Elasticsearch Query DSL syntax.
  • Supported query types: bool, match, match_all, match_phrase, term, terms, wildcard, prefix, fuzzy, range, regexp, query_string, simple_query_string, geo_distance, geo_bounding_box.
  • Text fields with a .keyword suffix are automatically stored in the index (max 256 chars) for term-level queries.
  • Enable OrchardCore.Search.Lucene.Worker only when running the same tenant on multiple instances (farm) with a file system index.
  • OrchardCore.Search.Lucene is an obsolete feature id kept for compatibility; it enables OrchardCore.Lucene. Use OrchardCore.Lucene in new recipes.
  • Reference permissions from OrchardCore.Lucene.LuceneSearchPermissions and OrchardCore.Indexing.Core.IndexingPermissions; the old OrchardCore.Lucene.Permissions.* and LuceneIndexPermissionHelper.ManageLuceneIndexes members were removed in Orchard Core 4.0.
  • All recipe JSON must be wrapped in { "steps": [...] }.
  • All C# classes must use the sealed modifier.

Enabling Lucene Features

json
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Search",
"OrchardCore.Lucene",
"OrchardCore.Indexing"
],
"disable": []
}
]
}

Creating a Lucene Index Profile (Recommended)

Use CreateOrUpdateIndexProfile to create a Lucene index for content items:

json
{
"steps": [
{
"name": "CreateOrUpdateIndexProfile",
"indexes": [
{
"Name": "BlogPostsLucene",
"IndexName": "blogposts",
"ProviderName": "Lucene",
"Type": "Content",
"Properties": {
"ContentIndexMetadata": {
"IndexLatest": false,
"IndexedContentTypes": ["BlogPost"],
"Culture": "any"
},
"LuceneIndexMetadata": {
"AnalyzerName": "standard",
"StoreSourceData": true
}
}
}
]
}
]
}
PropertyDescription
NameUnique display name for the index profile.
IndexNamePhysical index name on disk.
ProviderNameMust be "Lucene".
TypeSource category, typically "Content" for content items.
IndexLatestWhen true, indexes both published and draft items. Default false indexes published only.
IndexedContentTypesArray of content type names to include.
Culture"any" for all cultures or a specific culture code.
AnalyzerNameLucene analyzer name (e.g., "standard").
StoreSourceDataWhen true, stores source data for retrieval.

Legacy Index Creation (Obsolete)

The lucene-index step is obsolete but still supported:

json
{
"steps": [
{
"name": "lucene-index",
"Indices": [
{
"Search": {
"AnalyzerName": "standard",
"IndexLatest": false,
"IndexedContentTypes": [
"Article",
"BlogPost"
]
}
}
]
}
]
}

Reset Lucene Index

Restarts indexing from the beginning without deleting existing entries:

json
{
"steps": [
{
"name": "ResetIndex",
"indexNames": [
"BlogPostsLucene"
]
}
]
}

To reset all indices:

json
{
"steps": [
{
"name": "ResetIndex",
"IncludeAll": true
}
]
}

Rebuild Lucene Index

Deletes and recreates the full index content:

json
{
"steps": [
{
"name": "RebuildIndex",
"indexNames": [
"BlogPostsLucene"
]
}
]
}

To rebuild all indices:

json
{
"steps": [
{
"name": "RebuildIndex",
"IncludeAll": true
}
]
}

Creating a Lucene Query via Recipe

json
{
"steps": [
{
"name": "Queries",
"Queries": [
{
"Source": "Lucene",
"Name": "RecentBlogPosts",
"Index": "BlogPostsLucene",
"Template": "{ \"query\": { \"match_all\": {} }, \"size\": 10 }",
"ReturnContentItems": true
}
]
}
]
}

Index is the index profile Name (not the physical IndexName). Saved Lucene queries are executed through api/queries/{name}, Liquid (Queries.RecentBlogPosts | query), GraphQL and the Queries data source (see orchardcore-content-queries and orchardcore-data-sources). Since Orchard Core 4.0, the GraphQL field of a named query requires the ExecuteApi_{QueryName} permission (implied by ExecuteApiAll and ManageQueries).

Lucene Query Filters

Query filters retrieve records without considering boost values, similar to SQL filtering.

Bool filter with term and wildcard:

json
{
"query": {
"bool": {
"filter": [
{
"term": {
"Content.ContentItem.Published": "true"
}
},
{
"wildcard": {
"Content.ContentItem.DisplayText": "Main*"
}
}
]
}
}
}

Bool with must and filter (filtering by content type):

json
{
"query": {
"bool": {
"must": {
"term": {
"Content.ContentItem.ContentType.keyword": "Menu"
}
},
"filter": [
{
"term": {
"Content.ContentItem.Published": "true"
}
},
{
"wildcard": {
"Content.ContentItem.DisplayText": "Main*"
}
}
]
}
}
}

Full-text search with `query_string`:

json
{
"query": {
"query_string": {
"query": "Content.ContentItem.FullText:\"exploration\""
}
}
}

Full-text search with `simple_query_string` and default field:

json
{
"query": {
"simple_query_string": {
"query": "\"exploration\"",
"fields": [
"Content.ContentItem.FullText"
]
}
}
}

Web APIs

`api/lucene/content` — Executes a query and returns content items.

Verbs: POST and GET

ParameterExampleDescription
indexName"search"The name of the index to query.
query{ "query": { "match_all": {} }, "size": 10 }JSON query object.
parameters{ "size": 3 }JSON parameters object.

`api/lucene/documents` — Executes a query and returns Lucene documents (stored fields only).

Same parameters as api/lucene/content.

Both endpoints use the Api authentication scheme and require LuceneSearchPermissions.QueryLuceneApi. Their endpoint names are ApiGetLuceneContent, ApiPostLuceneContent, ApiGetLuceneDocuments and ApiPostLuceneDocuments (used by OpenAPI, see orchardcore-openapi).

Permissions

PermissionMemberNotes
ManageLuceneIndexesOrchardCore.Lucene.LuceneSearchPermissions.ManageLuceneIndexesManage Lucene indexes and run admin queries.
QueryLuceneApiOrchardCore.Lucene.LuceneSearchPermissions.QueryLuceneApiCall api/lucene/*. Implied by ManageLuceneIndexes.
QueryIndex_{IndexName}IndexingPermissions.CreateDynamicPermission(indexProfile)Query one index from the front-end search. Implied by ManageIndexes and QuerySearchIndex.
QuerySearchIndexOrchardCore.Indexing.Core.IndexingPermissions.QuerySearchIndexQuery any index.

A PermissionMigrations deferred task rewrites the legacy per-index role claims (QueryLucene{IndexName}Index) to the dynamic QueryIndex_{ProfileName} permissions once the index profiles exist.

Upgrading from 3.x

  • OrchardCore.Lucene.Permissions.ManageLuceneIndexes and OrchardCore.Lucene.LuceneIndexPermissionHelper.ManageLuceneIndexes were removed; use OrchardCore.Lucene.LuceneSearchPermissions.ManageLuceneIndexes.
  • OrchardCore.Lucene.Permissions.QueryLuceneApi was removed; use OrchardCore.Lucene.LuceneSearchPermissions.QueryLuceneApi.
  • OrchardCore.Search.Permissions.QuerySearchIndex was removed; use OrchardCore.Indexing.Core.IndexingPermissions.QuerySearchIndex.
  • Stored permission names are unchanged, so roles keep their permissions; only code referencing the removed members must change.
  • Each index is stored in one directory directly under the tenant's Lucene folder: characters that are invalid in file names are encoded (/ becomes _47) to prevent path traversal. An index whose full name contains such characters resolves to a new, empty directory after the upgrade; rebuild it.
  • The type of a Lucene query sort is now parsed with culture-invariant casing, so a lowercase type no longer fails on servers running a culture such as Turkish.

Lucene Worker

Enable OrchardCore.Search.Lucene.Worker to synchronize the local file system index across multiple instances. This creates a background task that keeps indexes in sync in a farm scenario.

Do not enable the Worker if:

  • You are running a single instance.
  • You are running on Azure App Services.
  • You are using Elasticsearch instead of Lucene.

Indexing Custom Data

Register a custom indexing source in Startup.cs:

csharp
using Microsoft.Extensions.Localization;
using OrchardCore.Modules;
namespace MyModule;
[Feature("MyModule.CustomLuceneIndex")]
public sealed class Startup : StartupBase
{
private readonly IStringLocalizer<Startup> _localizer;
public Startup(IStringLocalizer<Startup> localizer)
{
_localizer = localizer;
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddLuceneIndexingSource("CustomSource", o =>
{
o.DisplayName = _localizer["Custom Source"];
o.Description = _localizer["Create a Lucene index based on a custom data source."];
});
}
}

Automatic Field Mapping

Lucene automatically maps text fields with a .keyword suffix as stored values in the index, unless the document is already explicitly stored. Values longer than 256 characters are ignored. This enables any TextField to be searched using term queries by appending .keyword to the field name.

For example, to query by the exact DisplayText value, use Content.ContentItem.DisplayText.keyword in a term query.

All versions