Skip to content

Feature elasticsearch#603

Open
lauritssn wants to merge 9 commits into
emcie-co:developfrom
Werktoej:feature-elasticsearch
Open

Feature elasticsearch#603
lauritssn wants to merge 9 commits into
emcie-co:developfrom
Werktoej:feature-elasticsearch

Conversation

@lauritssn
Copy link
Copy Markdown
Contributor

Add Elasticsearch as a database, vector database and cache file storage. Initial version - needs a little more testing to ensure everything works as expected - especially on the retrieval part. Some files may need to be removed before merge.

@kichanyurd
Copy link
Copy Markdown
Contributor

Noted @lauritssn and great work!

FYI for readers - we're discussing progress on this on our Discord (https://discord.gg/duxWqxKk6J). AFAIK there's currently some extra testing to do before this can be merged, right?

@lauritssn
Copy link
Copy Markdown
Contributor Author

Noted @lauritssn and great work!

FYI for readers - we're discussing progress on this on our Discord (https://discord.gg/duxWqxKk6J). AFAIK there's currently some extra testing to do before this can be merged, right?

I think it works ok - tests are working and I have been running it on my own machine without errors. There is some stuff around the caching that requires a change in server.py I am unsure if is the good way to do it.

@lauritssn
Copy link
Copy Markdown
Contributor Author

lauritssn commented Oct 25, 2025

You can use this sign off: Signed-off-by: Laurits Søgaard Nielsen lsn@werktoej.dk

@kichanyurd
Copy link
Copy Markdown
Contributor

kichanyurd commented Oct 25, 2025

@lauritssn we can't modify your commit messages ourselves, they have to by you - unfortunately.

Fortunately - it's easy to fix. You can ask Claude/GPT for help with doing this but the process is basically:

  1. Setup sign off using the rules under CONTRIBUTING.md in git
  2. git rebase interactively to squash your commits into one, and finally amend it to include the sign off note

@lauritssn lauritssn force-pushed the feature-elasticsearch branch from 629a357 to 43aa790 Compare November 1, 2025 18:54
@lauritssn lauritssn force-pushed the feature-elasticsearch branch 2 times, most recently from e88da71 to 6c756ab Compare December 29, 2025 21:51
- Add ElasticsearchDocumentDatabase for document storage
- Add ElasticsearchVectorDatabase for vector similarity search
- Add SDK options to configure elasticsearch stores
- Add configuration documentation and examples
- Add comprehensive test coverage

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
- Add SortDirection enum and Cursor dataclass to persistence/common.py
- Add encode_cursor/decode_cursor utilities in app_modules/common.py
- Implement pagination in ElasticsearchDocumentCollection.find()
- Update capabilities.py to use FindResult interface
- Add pagination tests for Elasticsearch adapter

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
…h tests

- Fix delete_collection pattern to include _vecdb_ in index name matching
- Add unique test prefixes per test to prevent index conflicts
- Update tests for NullEmbedder rename (was NoOpEmbedder)
- Fix test_document_upgrade to create proper index mappings before inserting
- Add VectorDatabase type annotation and import to SDK

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
@lauritssn lauritssn force-pushed the feature-elasticsearch branch 2 times, most recently from d43a0c2 to 83c26fa Compare December 30, 2025 19:32
…es store

The association schema hasn't changed since 0.5.0, but the document
loader needs to handle the newer version strings.

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
@lauritssn lauritssn force-pushed the feature-elasticsearch branch from 83c26fa to 9b2358a Compare December 30, 2025 19:48
- Move elasticsearch_document_database.md to docs/adapters/persistence/
- Move elasticsearch_configuration.md to docs/adapters/vector_db/
- Update headers to match existing adapter documentation style
- Remove broken internal reference link

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
Comment thread src/parlant/core/guidelines.py Outdated

if doc["version"] == "0.5.0":
# 0.5.0+ all use the same schema - no migration needed
if doc["version"] in ("0.5.0", "0.6.0", "0.7.0"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation of this bug! But actually, this is not a clean fix.
We want to update every document to the latest version. For 0.5.0 and 0.6.0, we want to update the document to 0.7.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - should be fixed now

Comment thread src/parlant/sdk.py Outdated
session_store: Literal["transient", "local"] | str | SessionStore = "transient",
customer_store: Literal["transient", "local"] | str | CustomerStore = "transient",
variable_store: Literal["transient", "local"] | str | ContextVariableStore = "transient",
session_store: Literal["transient", "local", "elasticsearch"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since very few users are using Elasticsearch for persistence, we don't want to include it in the SDK.
With MongoDB, even though we didn't include it in the options, we implemented it, so you need to set an environment variable to enable it.
What we did with the other adapters is add an explanation to the Elasticsearch.md file on how to enable this adapter using configure_container.
Please take a look at the docs/adapters/persistence/snowflake.md for an example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see Elasticsearch as an option for stores. The SDK should remain as it was.

- Remove 'elasticsearch' from session_store, customer_store, variable_store,
  and cache_store Literal types in SDK Server constructor
- Keep 'elasticsearch' as a valid option for vector_store
- Update persistence elasticsearch.md with SDK/Module Setup section showing
  how to use configure_container for Elasticsearch persistence (like Snowflake)
- Update vector_db elasticsearch.md with Quick Start showing both direct SDK
  usage (vector_store='elasticsearch') and advanced configure_container approach
- Add new SDK exports: AgentStore, SessionDocumentStore, CustomerDocumentStore,
  ContextVariableDocumentStore, IdGenerator, EventEmitterFactory, VectorDatabase
- Update installation examples to use uv instead of pip

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
Update _association_document_loader to migrate all older document versions
(0.3.0, 0.4.0, 0.5.0, 0.6.0) to the latest version 0.7.0 instead of just
passing them through or migrating to an intermediate version.

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
Remove the remaining "elasticsearch" option from vector_store Literal type
and its implementation code. Users who want to use Elasticsearch for vector
storage should use configure_container to set it up, similar to other
adapters like Snowflake and Qdrant.

This keeps the SDK unchanged from its original state before the Elasticsearch
PR, as requested by the maintainers.

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
The SDK should remain unchanged. Users who want to use Elasticsearch
should use configure_container to set it up, as documented in
docs/adapters/persistence/elasticsearch.md and
docs/adapters/vector_db/elasticsearch.md.

Signed-off-by: Laurits Søgaard Nielsen <lsn@werktoej.dk>
@lauritssn
Copy link
Copy Markdown
Contributor Author

@mc-dorzo Can you please check if everything is as expected now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants