Automated query generation converts a natural-language question into an executable database query. In a knowledge-graph system, it combines structured user intent, an LLM-friendly schema, prompt constraints, and execution feedback to formulate and refine Cypher. section 14.7 section 15.1.5
A reliability-focused pipeline typically proceeds through these stages:
- Prepare the question, annotated graph schema, intent-dependent requirements, examples, optional selection state, and an explicit output format. section 14.7.2
- Ask the model to identify relationships it may traverse and explain its reasoning before producing the final Cypher query. section 14.7.3
- Execute the generated query, capture database errors, and retry the text-to-Cypher stage when execution fails. section 15.1.5
- Route successful results either directly to completion or through summarization according to the requested output type. section 15.1.5
Crime investigation query
For the request “Return one crime node currently under investigation,” the system detects the graph-oriented response, generates Cypher with the active-investigation constraint, displays a crime node, and explains its interpretation and execution. section 15.3.1
Figure 14.11 The complete flow of transforming a natural language question into a Cypher query, showing how three inputs are processed through structured prompt components. The process is organized into three stages (Input processing, Context building, and Final guidelines) that culminate in structured JSON output.
The pipeline diagram shows how question, schema, and contextual requirements move through input processing, context building, and final guidelines into structured query output. section 14.7.2
