Text2cypher converts natural-language questions into Cypher queries for structured graph-database retrieval. It complements similarity search when questions require traversal, aggregation, or other database-specific operations. section 4.2 section 5.1.1
Improve generated queries with:
- Provide the graph schema and terminology mappings so the model can select valid properties and relationships. section 4.3.1
- Add knowledge-graph-specific few-shot question-and-query pairs when the model repeats schema mistakes. section 4.3.1
- Use specialized retrievers when generic text2cypher repeatedly fails on a narrow class of questions. section 5.1.1
Traversal instead of a property lookup
For a question about a movie’s production country, replace a query that reads m.country with a traversal from Movie to Country through PRODUCED_IN, returning c.name. section 4.3.1
Listing 4.1 Cypher query
MATCH (:Reviewer)-[r:REVIEWED]->(m:Movie)<-[:DIRECTED]-(:Director {name: 'Steven Spielberg'})
RETURN m.title, AVG(r.score) AS avg_rating
ORDER BY avg_rating DESC
LIMIT 3
Aggregates reviewer scores for Spielberg’s movies, orders them, and returns the top three. section 4.2
