Skip to content

Your first NexQL query

NexQL is a semantic query language developed for FactEngine. It expresses a question using the object types and relationship readings in a model, then supports deterministic translation to SQL or Cypher.

This walkthrough uses a cinema model to build a query step by step. To run the examples, use FactEngine with the matching model and a connected database.

Ask “What films are there?”

WHICH Film

Film is an object type in the cinema model. WHICH selects it for the results. You do not need a RETURN clause.

Ask “What films are playing at the Rialto?”

WHICH Film is showing at (Cinema:'Rialto')

Read it in three parts:

PartMeaning
WHICH FilmSelect films.
is showing atFollow a relationship reading defined by the model.
(Cinema:'Rialto')Constrain Cinema to the specified value.

Object names and relationship readings come from your model. NexQL is close to natural language, but arbitrary English is not automatically a valid query.

Ask “What films are playing at the Rialto on 1 April 2023 at 10am?”

WHICH Film is showing at (Cinema:'Rialto')
on (DateTime:'2023-04-01 10:00')

The date and time narrow the matching showings. Line breaks here make the query easier to read.

WHICH Film is showing at WHICH Cinema at WHICH DateTime

Each WHICH selects another object type to return. For each selected object type, NexQL returns the fields of the first-found uniqueness constraint. If none is found, it returns the primary key.

Using the cinema vocabulary, write a query for films showing at the Great Western Cinema.

See the query
WHICH Film is showing at (Cinema:'Great Western Cinema')

Continue with choosing results or the agent workflow.