Skip to main content

Validate and Optimize Queries

The validate and optimize j1ql endpoints are used to validate and/or optimize j1ql queries.

Validate queries

The validate endpoint takes in an array of queries sent as a json object in the request body. It returns an array of objects containing the query and a boolean flag indicating whether the query is valid or not.

Sample request

POST /j1ql/validate
{
"queries": [
"Find Person as p that relates to User"
]
}

Sample response

[
{
"query": "Find Person as p that relates to User",
"valid": true
}
]

Optimize queries

The optimize endpoint validates and optimizes a query. It takes in an array of queries and return an array of objects containing the original query, the optimized query, a list of optimizations that are suggested, and a valid boolean flag indicating whether the query is valid or not.

Sample request

POST /j1ql/optimize
{
"queries": [
"Find Person as p that relates to User"
]
}

Sample response

[
{
"valid": true,
"originalQuery": "FIND Person AS p\n THAT RELATES TO User",
"optimizations": [
{
"name": "Add Relationship Direction(s) (Suggested)",
"description": "Many relationships can be made faster by supplying a direction. By querying the data catalog, we can supply a direction for relationships between known entity pairings where the relationship only goes in one direction."
}
],
"optimizedQuery": "FIND Person AS p\n THAT RELATES TO << User"
}
]