Orchardcore ai documents elasticsearch

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore ai documents elasticsearch is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for indexing CrestApps Orchard Core AI Documents with Elasticsearch. Covers Elasticsearch index profiles, the embedding deployment picked from the embedding slot (textEmbedding capability), dense vector chunk mappings, k-nearest-neighbor retrieval, default search fields, and scoped RAG results

How to use this skill

Skill file

Orchard Core AI Documents Elasticsearch

Configure Elasticsearch document retrieval

You are an Orchard Core expert. Configure Elasticsearch as the vector indexing and

retrieval backend for CrestApps AI Documents. Use the provider-created index profile,

embedding dimensions, and reference-scoped retrieval rather than hand-written queries.

Guidelines

Feature registration

| Registration | Purpose |

|---|---|

| AIDocumentElasticsearchIndexProfileHandler | Defines chunk fields, dense vectors, and default textual fields. |

| AIDocumentElasticsearchDocumentIndexHandler | Maps document chunk records into Elasticsearch documents. |

| ElasticsearchVectorSearchService | Runs filtered k-nearest-neighbor chunk retrieval. |

| AddElasticsearchIndexingSource | Adds AI Documents (Elasticsearch) to Search → Indexing. |

Enable document indexing

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.AI.Documents.ChatInteractions",
        "CrestApps.OrchardCore.AI.Documents.Elasticsearch",
        "OrchardCore.Elasticsearch"
      ],
      "disable": []
    }
  ]
}

Enable CrestApps.OrchardCore.AI.Documents.Pdf or

CrestApps.OrchardCore.AI.Documents.OpenXml separately for optional extraction

support. These processor features are not required by Elasticsearch itself.

Create and use an index profile

  1. Configure the Orchard Core Elasticsearch connection and ensure the application can create and query indexes.
  2. Create an embedding deployment that declares the textEmbedding capability; the

picker lists deployments in the embedding slot only (see orchardcore-ai-model-capabilities).

  1. In Search → Indexing, create AI Documents (Elasticsearch).
  2. Select the embedding deployment. It is stored in

DataSourceIndexProfileMetadata.EmbeddingDeploymentName and locked once the index exists.

  1. Select the profile as the Index profile in the documents section of

Settings → Artificial Intelligence.

  1. Upload or reindex documents and test a query that is unique to an uploaded source.

Changing embeddings after data has been indexed can make existing vectors incompatible.

Create a compatible new index and reindex rather than mixing different dimensions.

Provider-managed mappings

AIDocumentElasticsearchIndexProfileHandler configures:

| Field | Elasticsearch mapping |

|---|---|

| chunkId | Keyword and index key field |

| documentId | Keyword |

| content | Text |

| fileName | Keyword |

| referenceId | Keyword |

| referenceType | Keyword |

| chunkIndex | Integer |

| embedding | Indexed dense_vector with cosine similarity |

The dense vector dimensions come from the profile's selected embedding deployment.

When no default Elasticsearch query fields exist, the handler sets content as the

default textual search field. Keep chunkId stable so indexing updates and deletes

target the correct document.

Vector retrieval behavior

ElasticsearchVectorSearchService performs k-nearest-neighbor search over

embedding in the selected index. It requests K = topN and NumCandidates = topN * 10

and applies a Boolean filter requiring both:

The service reads content, chunk index, document ID, and file name from each hit,

sorts by score descending, and returns no more than topN chunks. Invalid Elasticsearch

responses and exceptions are logged and yield an empty result set.

RAG request sequence

  1. AI Documents generates an embedding for the current prompt.
  2. It resolves ElasticsearchVectorSearchService with the Elasticsearch provider key.
  3. The service searches the profile's IndexFullName and applies the two context filters.
  4. The best chunk text and file metadata become model context.
  5. The model answers using retrieved content without leaking chunks from a different reference.

Example feature recipe

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.AI.Documents.ChatSessions",
        "CrestApps.OrchardCore.AI.Documents.Elasticsearch",
        "CrestApps.OrchardCore.AI.Documents.Pdf"
      ],
      "disable": []
    }
  ]
}

This enables session document upload, Elasticsearch retrieval, and PDF extraction.

Configure the index profile and embedding deployment in the admin UI afterward.

Troubleshooting

| Symptom | Check |

|---|---|

| Index source is absent | Confirm OrchardCore.Elasticsearch and the exact document backend feature are enabled. |

| Index mapping rejects vectors | Ensure the selected embedding dimensions match the generated dense_vector mapping and target Elasticsearch capabilities. |

| RAG produces no sources | Verify indexing completed, content is non-empty, and the document context selects this profile. |

| Expected chunks are missing | Verify referenceId and referenceType; the service deliberately filters both. |

| Search errors appear in logs | Check endpoint, authentication, TLS, index availability, and application network access. |

| Text search behavior is unexpected | Inspect the profile default query metadata; this handler defaults it to content only when no fields are already selected. |

Operational and security notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.