Orchard Core AI Memory Elasticsearch
Configure Elasticsearch memory indexing
You are an Orchard Core expert. Configure Elasticsearch as the persistent AI Memory
vector backend while maintaining user isolation, stable provider mappings, and
embedding compatibility.
Guidelines
- Enable the exact feature ID
CrestApps.OrchardCore.AI.Memory.Elasticsearch.
- Its manifest depends on
CrestApps.OrchardCore.AI.Memory and OrchardCore.Elasticsearch; the base memory feature is enabled by dependency.
- Create AI Memory (Elasticsearch) from Search → Indexing, select an embedding deployment, and choose it in Settings → Artificial Intelligence → Memory.
- The provider is registered as keyed
IMemoryVectorSearchService using ElasticsearchConstants.ProviderName.
- Vector similarity never replaces authorization. Every retrieval must remain filtered to the current authenticated
userId.
- Install this package in the web or startup project and secure the Elasticsearch connection with production secret configuration.
- Store only durable non-sensitive preferences and facts; do not persist credentials, tokens, financial data, or private keys as AI memory.
Provider registrations
| Registration |
Purpose |
AIMemoryElasticsearchIndexProfileHandler |
Defines memory mappings, vector dimensions, and default search fields. |
AIMemoryElasticsearchDocumentIndexHandler |
Maps persisted memory records to Elasticsearch documents. |
ElasticsearchMemoryVectorSearchService |
Runs user-filtered k-nearest-neighbor queries. |
AddElasticsearchIndexingSource |
Adds AI Memory (Elasticsearch) at Search → Indexing. |
Enable the backend
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.AI",
"CrestApps.OrchardCore.AI.Memory.Elasticsearch",
"OrchardCore.Elasticsearch"
],
"disable": []
}
]
}
The core AI Memory feature comes from the provider dependency. Use the Azure AI Search
provider instead when that is the selected index service; do not configure both as
masters unless the application intentionally manages separate indexes and migration.
Configure the profile
- Configure Orchard Core Elasticsearch connectivity and permissions.
- Configure an embedding deployment compatible with Elasticsearch dense vectors.
- Create AI Memory (Elasticsearch) under Search → Indexing.
- Select the embedding deployment and save.
- Select the profile in the AI Memory site setting.
- Enable user memory for the desired AI profile or interaction, then test as an authenticated user.
The profile's embedding deployment defines dense-vector dimensions. If dimensions
change, create a new compatible index and reindex instead of mixing incompatible vectors.
Managed mappings
| Field |
Elasticsearch mapping |
memoryId |
Keyword and index key |
userId |
Keyword |
name |
Text |
description |
Text |
content |
Text |
updatedUtc |
Date |
embedding |
Indexed dense_vector using cosine similarity |
The handler uses selected embedding dimensions for embedding. When the profile has
no default Elasticsearch query fields, it assigns name, description, and content.
Do not change the key field away from memoryId; indexing updates and deletions depend
on the stable identifier.
Vector retrieval behavior
ElasticsearchMemoryVectorSearchService searches the profile IndexFullName with:
embedding as the k-nearest-neighbor field
K = topN
NumCandidates = topN * 10
- a
userId term filter for the current authenticated user
It maps memory ID, name, description, content, updated time, and score from each hit.
Results without content are discarded, then remaining results are ordered by score and
limited to topN. Invalid responses and exceptions are logged and produce an empty
result set.
Retrieval sequence
- The current authenticated user submits a memory-aware request.
- The query is embedded with the memory profile deployment.
- The Elasticsearch keyed memory service executes filtered k-nearest-neighbor search.
- Relevant user-specific records become private retrieval context or tool results.
- The application never exposes hits from another user's
userId.
Troubleshooting
| Symptom |
Check |
| AI Memory index source is absent |
Enable OrchardCore.Elasticsearch and the exact provider feature. |
| Index rejects a mapping |
Verify Elasticsearch version support and the selected embedding vector dimensions. |
| No memories are returned |
Verify an authenticated identity, selected master profile, saved records, and index health. |
| Search error is logged |
Inspect Elasticsearch endpoint, TLS, credentials, index availability, and network access. |
| Results cross user boundaries |
Stop and correct the query. Preserve the mandatory userId term filter. |
| Textual memory queries behave unexpectedly |
Review default query metadata; the handler assigns Name, Description, and Content only when no defaults exist. |
Security and operations
- Use TLS, least-privilege credentials, and restricted network access for Elasticsearch.
- Validate user isolation with two distinct accounts before production rollout.
- Reindex after an intentional embedding deployment or vector-dimension change.
- Keep users informed about memory retention and support their removal requests.
- Do not bypass the shared memory store lifecycle with direct index writes unless the application also preserves indexing consistency.
Profile maintenance
The provider handler initializes, creates, and updates Elasticsearch index profiles.
It sets mapping metadata only for profiles it can handle:
- Confirm the profile provider is Elasticsearch.
- Confirm the selected embedding deployment is still available and dimension-compatible.
- Save the profile through Search → Indexing so managed properties remain valid.
- Preserve
memoryId as the key and the userId keyword mapping for filtering.
- Reindex through the shared memory lifecycle after mapping or embedding changes.
Add custom fields only with new names. Do not replace the dense_vector field,
change its cosine similarity setting, or remove userId from an index that backs
shared authenticated-user memory.
Index migration checklist
- Create a new index profile for an embedding deployment with changed dimensions.
- Create and validate the target Elasticsearch index before selecting it as master.
- Reindex memory records using the normal indexing service rather than direct bulk writes.
- Test semantic search, save, update, removal, and self-service memory clearing.
- Monitor index health and failed indexing work before diagnosing semantic retrieval.
1---2name: orchardcore-ai-memory-elasticsearch3description: Skill for indexing CrestApps Orchard Core AI Memory with Elasticsearch. Covers memory field mappings, dense vectors, k-nearest-neighbor retrieval, default query fields, user isolation, and Elasticsearch operations. Use this skill when requests mention AI Memory Elasticsearch, AIMemoryElasticsearchIndexProfileHandler, ElasticsearchMemoryVectorSearchService, memory vector indexes, or Elasticsearch user-memory retrieval. Strong matches include work with CrestApps.OrchardCore.AI.Memory.Elasticsearch, IMemoryVectorSearchService, AIMemoryElasticsearchDocumentIndexHandler, AddElasticsearchIndexingSource, ElasticsearchIndexMetadata, and MemoryConstants.IndexingTaskType.4license: Apache-2.05---67# Orchard Core AI Memory Elasticsearch89## Configure Elasticsearch memory indexing1011You are an Orchard Core expert. Configure Elasticsearch as the persistent AI Memory12vector backend while maintaining user isolation, stable provider mappings, and13embedding compatibility.1415### Guidelines1617- Enable the exact feature ID `CrestApps.OrchardCore.AI.Memory.Elasticsearch`.18- Its manifest depends on `CrestApps.OrchardCore.AI.Memory` and `OrchardCore.Elasticsearch`; the base memory feature is enabled by dependency.19- Create **AI Memory (Elasticsearch)** from **Search → Indexing**, select an embedding deployment, and choose it in **Settings → Artificial Intelligence → Memory**.20- The provider is registered as keyed `IMemoryVectorSearchService` using `ElasticsearchConstants.ProviderName`.21- Vector similarity never replaces authorization. Every retrieval must remain filtered to the current authenticated `userId`.22- Install this package in the web or startup project and secure the Elasticsearch connection with production secret configuration.23- Store only durable non-sensitive preferences and facts; do not persist credentials, tokens, financial data, or private keys as AI memory.2425### Provider registrations2627| Registration | Purpose |28|---|---|29| `AIMemoryElasticsearchIndexProfileHandler` | Defines memory mappings, vector dimensions, and default search fields. |30| `AIMemoryElasticsearchDocumentIndexHandler` | Maps persisted memory records to Elasticsearch documents. |31| `ElasticsearchMemoryVectorSearchService` | Runs user-filtered k-nearest-neighbor queries. |32| `AddElasticsearchIndexingSource` | Adds **AI Memory (Elasticsearch)** at Search → Indexing. |3334### Enable the backend3536```json37{38 "steps": [39 {40 "name": "Feature",41 "enable": [42 "CrestApps.OrchardCore.AI",43 "CrestApps.OrchardCore.AI.Memory.Elasticsearch",44 "OrchardCore.Elasticsearch"45 ],46 "disable": []47 }48 ]49}50```5152The core AI Memory feature comes from the provider dependency. Use the Azure AI Search53provider instead when that is the selected index service; do not configure both as54masters unless the application intentionally manages separate indexes and migration.5556### Configure the profile57581. Configure Orchard Core Elasticsearch connectivity and permissions.592. Configure an embedding deployment compatible with Elasticsearch dense vectors.603. Create **AI Memory (Elasticsearch)** under **Search → Indexing**.614. Select the embedding deployment and save.625. Select the profile in the AI Memory site setting.636. Enable user memory for the desired AI profile or interaction, then test as an authenticated user.6465The profile's embedding deployment defines dense-vector dimensions. If dimensions66change, create a new compatible index and reindex instead of mixing incompatible vectors.6768### Managed mappings6970| Field | Elasticsearch mapping |71|---|---|72| `memoryId` | Keyword and index key |73| `userId` | Keyword |74| `name` | Text |75| `description` | Text |76| `content` | Text |77| `updatedUtc` | Date |78| `embedding` | Indexed `dense_vector` using cosine similarity |7980The handler uses selected embedding dimensions for `embedding`. When the profile has81no default Elasticsearch query fields, it assigns `name`, `description`, and `content`.82Do not change the key field away from `memoryId`; indexing updates and deletions depend83on the stable identifier.8485### Vector retrieval behavior8687`ElasticsearchMemoryVectorSearchService` searches the profile `IndexFullName` with:8889- `embedding` as the k-nearest-neighbor field90- `K = topN`91- `NumCandidates = topN * 10`92- a `userId` term filter for the current authenticated user9394It maps memory ID, name, description, content, updated time, and score from each hit.95Results without content are discarded, then remaining results are ordered by score and96limited to `topN`. Invalid responses and exceptions are logged and produce an empty97result set.9899### Retrieval sequence1001011. The current authenticated user submits a memory-aware request.1022. The query is embedded with the memory profile deployment.1033. The Elasticsearch keyed memory service executes filtered k-nearest-neighbor search.1044. Relevant user-specific records become private retrieval context or tool results.1055. The application never exposes hits from another user's `userId`.106107### Troubleshooting108109| Symptom | Check |110|---|---|111| AI Memory index source is absent | Enable `OrchardCore.Elasticsearch` and the exact provider feature. |112| Index rejects a mapping | Verify Elasticsearch version support and the selected embedding vector dimensions. |113| No memories are returned | Verify an authenticated identity, selected master profile, saved records, and index health. |114| Search error is logged | Inspect Elasticsearch endpoint, TLS, credentials, index availability, and network access. |115| Results cross user boundaries | Stop and correct the query. Preserve the mandatory `userId` term filter. |116| Textual memory queries behave unexpectedly | Review default query metadata; the handler assigns Name, Description, and Content only when no defaults exist. |117118### Security and operations119120- Use TLS, least-privilege credentials, and restricted network access for Elasticsearch.121- Validate user isolation with two distinct accounts before production rollout.122- Reindex after an intentional embedding deployment or vector-dimension change.123- Keep users informed about memory retention and support their removal requests.124- Do not bypass the shared memory store lifecycle with direct index writes unless the application also preserves indexing consistency.125126### Profile maintenance127128The provider handler initializes, creates, and updates Elasticsearch index profiles.129It sets mapping metadata only for profiles it can handle:1301311. Confirm the profile provider is Elasticsearch.1322. Confirm the selected embedding deployment is still available and dimension-compatible.1333. Save the profile through **Search → Indexing** so managed properties remain valid.1344. Preserve `memoryId` as the key and the `userId` keyword mapping for filtering.1355. Reindex through the shared memory lifecycle after mapping or embedding changes.136137Add custom fields only with new names. Do not replace the `dense_vector` field,138change its cosine similarity setting, or remove `userId` from an index that backs139shared authenticated-user memory.140141### Index migration checklist142143- Create a new index profile for an embedding deployment with changed dimensions.144- Create and validate the target Elasticsearch index before selecting it as master.145- Reindex memory records using the normal indexing service rather than direct bulk writes.146- Test semantic search, save, update, removal, and self-service memory clearing.147- Monitor index health and failed indexing work before diagnosing semantic retrieval.