Skip to content

Add Cypher 25 SEARCH clause for vector retrievers#488

Open
oskarhane wants to merge 13 commits intoneo4j:mainfrom
oskarhane:oskar/cypher25-search-clause
Open

Add Cypher 25 SEARCH clause for vector retrievers#488
oskarhane wants to merge 13 commits intoneo4j:mainfrom
oskarhane:oskar/cypher25-search-clause

Conversation

@oskarhane
Copy link
Member

Summary

  • Auto-detect Neo4j 2026.01+ and route vector/hybrid queries through the new Cypher 25 SEARCH ... WHERE clause for in-index filtered ANN search
  • Classify filters as SEARCH-compatible (simple AND comparisons) vs incompatible ($or, $in, $like) with automatic fallback to procedure path + warning log
  • Add filterable_properties param to create_vector_index() for WITH [n.prop] clause
  • All 4 retrievers supported: VectorRetriever, VectorCypherRetriever, HybridRetriever, HybridCypherRetriever

Closes #485

Test plan

  • 940 unit tests pass (95% coverage)
  • 6 E2E tests pass against Neo4j 2026.02.2-enterprise in Docker
  • mypy strict, ruff lint/format clean
  • CI passes

🤖 Generated with Claude Code

oskarhane and others added 10 commits March 13, 2026 15:31
… detection + supports_search_clause

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ication for SEARCH-compatible predicates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…query builder

Add _build_search_clause_vector_query() to neo4j_queries.py generating
MATCH...SEARCH...SCORE Cypher with optional WHERE from FilterClassification.
8 unit tests covering no-filter, with-predicates, escaping, clause ordering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…perties to create_vector_index

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lause routing into vector retrievers

VectorRetriever and VectorCypherRetriever now detect Neo4j 2026.01+ and
route to SEARCH clause query builder when filters are compatible (or absent).
Falls back to procedure path on older versions or incompatible filters with
warning log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lause into hybrid retrievers

Add SEARCH clause routing to HybridRetriever and HybridCypherRetriever.
Uses SEARCH for both vector and fulltext via CALL () { UNION } on 2026.01+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ker-compose for e2e tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… tests for SEARCH clause

Add 23 tests covering hybrid SEARCH query builders + routing logic
for all 4 retrievers (SEARCH path vs procedure path). 940 tests pass, 95% coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…TH clause order

Add 6 E2E tests for SEARCH clause vector search against Neo4j 2026.02.
Fix create_vector_index: WITH clause must come before OPTIONS in Neo4j 2026.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ause + filterable properties

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@oskarhane oskarhane requested a review from a team as a code owner March 13, 2026 16:24
oskarhane and others added 3 commits March 13, 2026 17:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Hybrid SEARCH clause now uses VECTOR INDEX for vector + procedure for
  fulltext (SEARCH doesn't support FULLTEXT INDEX)
- Vector retrievers catch PropertyNotFound and fall back to procedure
  when filtered properties aren't declared as filterable on the index
- CI matrix: test on both neo4j:5-enterprise and neo4j:latest (2026.x)
- SEARCH clause e2e tests marked with @pytest.mark.search_clause

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Support Cypher 25 SEARCH clause with in-index filtering for vector retrievers

1 participant