feat: Add Gremlin query language support for Neptune Database #1052
+860
−50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds experimental support for Apache TinkerPop Gremlin as an alternative query language for AWS Neptune Database, alongside the existing openCypher support. This enables users to choose their preferred query language and opens the door for future support of other Gremlin-compatible databases (Azure Cosmos DB, JanusGraph, DataStax Graph, etc.).
Motivation
While Graphiti currently supports AWS Neptune Database using openCypher, Neptune also natively supports Gremlin, which:
Key Features
QueryLanguageenum (CYPHER, GREMLIN) for explicit language selectionNeptuneDriversupporting both Cypher and Gremlingremlinpythonis not installedImplementation Details
Core Infrastructure
QueryLanguageenum andquery_languagefield to base driver_run_cypher_query()and_run_gremlin_query()methodsgremlin_match_node_by_property()gremlin_match_nodes_by_uuids()gremlin_match_edge_by_property()gremlin_get_outgoing_edges()gremlin_bfs_traversal()gremlin_delete_all_nodes()gremlin_delete_nodes_by_group_id()gremlin_retrieve_episodes()gremlin_cosine_similarity_filter()(placeholder)Maintenance Operations
clear_data()to support both query languagesTesting & Documentation
Dependencies
gremlinpython>=3.7.0to neptune and dev extrasUsage Example
Installation
# Install with Neptune and Gremlin support pip install graphiti-core[neptune]Current Limitations
Supported ✅
Not Yet Supported ❌
search_utils.pyGremlin implementation (marked for future work)Why OpenSearch is Still Used
Neptune's Gremlin implementation doesn't include native fulltext search or vector similarity functions. These operations continue to use the existing OpenSearch (AOSS) integration, which provides:
This hybrid approach (Gremlin for graph traversal + OpenSearch for search) is a standard pattern for production Neptune applications.
Testing
Breaking Changes
None. This is fully backward compatible:
CYPHER(existing behavior unchanged)gremlinpythonis an optional dependencyFuture Work
The following enhancements are planned for future iterations:
Complete search_utils.py Gremlin Support
Broader Database Support
Performance Benchmarking
Checklist
Related Issues
This addresses feature requests for:
Additional Notes
See
GREMLIN_FEATURE.mdin the repository for complete technical documentation, including detailed implementation notes and architecture decisions.🤖 Generated with Claude Code