Skip to content

Fixes #564: Add Neo4j vector search using 2026.01 syntax and in-index filtering#565

Open
vga91 wants to merge 2 commits intolangchain4j:mainfrom
vga91:issue-564
Open

Fixes #564: Add Neo4j vector search using 2026.01 syntax and in-index filtering#565
vga91 wants to merge 2 commits intolangchain4j:mainfrom
vga91:issue-564

Conversation

@vga91
Copy link
Contributor

@vga91 vga91 commented Feb 13, 2026

Issue

Closes #564

Change

This PR updates the Neo4jEmbeddingStore to support the new Vector Search syntax introduced in Neo4j version 2026.01 (Preview), enabling native in-index filtering.

Implementation Details:

  1. New SearchType Configuration:
    Introduced a SearchType enum to control the retrieval strategy:

    • VECTOR_FUNCTION (Default): Uses legacy db.index.vector.queryNodes or cosine similarity functions. Compatible with Neo4j 5.x.
    • MATCH_SEARCH_CLAUSE: Enables the new GQL standard MATCH ... SEARCH ... syntax. This allows efficient pre-filtering directly within the vector index search (requires Neo4j 2026.01+).
  2. Metadata Configuration:
    Added a filterMetadata list parameter to the builder. This is required when using MATCH_SEARCH_CLAUSE to specify which metadata keys should be included in the vector index for native filtering.

  3. Test Refactoring & Coverage:

    • Extracted common test logic into a new abstract Neo4jEmbeddingStoreBaseTest.
    • Maintained Neo4jEmbeddingStoreTest for backward compatibility testing (runs against default Neo4j 5.26).
    • Added a new Neo4jEmbeddingStoreWith2026SyntaxTest which runs against the neo4j:2026.01-preview Docker image to verify the new syntax and filtering capabilities.

Reference:
This implementation aligns with the features described in: Vector Search with Filters in Neo4j v2026.01.

General checklist

  • There are no breaking changes
  • I have added unit and integration tests for my change
  • I have manually run all the unit tests in all modules, and they are all green
  • I have manually run all integration tests in the module I have added/changed, and they are all green
  • I have added/updated the documentation
  • I have added an example in the examples repo (only for "big" features)
  • I have added/updated Spring Boot starter(s) (if applicable)

Checklist for adding new maven module

  • I have added my new module in the root pom.xml and langchain4j-community-bom/pom.xml

Checklist for adding new embedding store integration

  • I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT
  • I have added a {NameOfIntegration}EmbeddingStoreRemovalIT that extends from EmbeddingStoreWithRemovalIT

Checklist for changing existing embedding store integration

  • I have manually verified that the Neo4jEmbeddingStore works correctly with the data persisted using the latest released version of LangChain4j

@Martin7-1 Martin7-1 added enhancement New feature or request P2 High priority P3 Medium priority theme: embedding store Issues/PRs related to embedding store labels Feb 15, 2026
Copy link
Collaborator

@Martin7-1 Martin7-1 left a comment

Choose a reason for hiding this comment

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

@vga91 Thanks for your contribution!

I think that hardcoding if-else statements into the embedding store will reduce scalability, and maintenance will be very troublesome if new SearchType is added later. Is it possible to implement the logic for different search types using a separate SearchStrategy (e.g. VectorFunctionSearchStrategy and MatchSearchClauseSearchStrategy), so that if Neo4j has new updates, users can also implement their own SearchStrategy?

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

Labels

enhancement New feature or request P2 High priority P3 Medium priority theme: embedding store Issues/PRs related to embedding store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Neo4j vector search using 2026.01 syntax and in-index filtering

2 participants

Comments