Skip to content

Real testcontainers tests for Elasticsearch (fixes reconnect + es-py 9.x break) — #829 - #834

Merged
AmitoVrito merged 2 commits into
mainfrom
feat/issue-829-testcontainers-elasticsearch
Jul 21, 2026
Merged

AmitoVrito merged 2 commits into
mainfrom
feat/issue-829-testcontainers-elasticsearch

Conversation

@AmitoVrito

Copy link
Copy Markdown
Collaborator

Summary

Next backend in epic #829: Elasticsearch converted to real testcontainers tests. Deep testing against a real elasticsearch:8.15 found 2 mock-hidden bugs (#833).

Bugs found & fixed

  • No reconnect persistence — search() returned [] after a reconnect (short-circuited on a missing cached dim), so a fresh instance never found already-indexed vectors. Proven: write with one client, read with a second → empty.
  • Deprecated/removed body= — indices.create(body=) / search(body=) are deprecated in elasticsearch-py 8.x and removed in 9.x; the store breaks entirely on the 9.x client. Now uses mappings= / knn= kwargs.

Verification (real data, real queries)

Inserts real docs into a real ES index, refreshes, runs real kNN vector search, asserts the true nearest neighbour + _score order + metadata round-trip; persistence test reads back through a second client. 7/7 pass against elasticsearch:8.15.3, wired into the CI integration job.

Commits

  • fix(retrieval): make ElasticsearchVectorStore work on reconnect and modern clients (#833)
  • ci(test): add elasticsearch to the integration group and CI job (#829)

Part of #829.

…odern clients (#833)

Only ever tested with a MagicMock, which hid two bugs found against a real
Elasticsearch: search() returned [] after a reconnect (it short-circuited on a
missing cached dimension), and it used the `body=` argument that is deprecated in
elasticsearch-py 8.x and removed in 9.x, so the store breaks entirely on the 9.x
client.

Use modern kwargs — `indices.create(mappings=...)` and `search(knn=..., size=...)`
— and drop the `_dims is None` guard; `_search_sync` returns [] on NotFoundError,
which covers both search-before-add and a genuinely missing index while letting a
reconnected instance find already-indexed vectors.

Adds real elasticsearch:8.15 testcontainers tests (kNN nearest-neighbour ranking,
metadata filter, top_k, persistence, negatives) and removes the MagicMock test.

Part of #829. Closes #833.
@AmitoVrito
AmitoVrito merged commit b5fecd5 into main Jul 21, 2026
15 checks passed
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.

1 participant