Generate cypher queries with OpenAI GPT-3 (davinci-codex engine)

What needed was to give some examples of CREATE queries of nodes and relationships, so it can understand the schema.
Then you ask with natural language what query to generate:

it can write queries even for Suffix string search using ENDS WITH and the engine could understand that an actor is a person with relation ACTED_IN .

"""
Create an openCypher query filtering only the actors whose names end with "s"
"""
query = """
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name ENDS WITH 's'
RETURN p
"""
1 Like