AlgorithmQueryBuilder
age-schema-client / AlgorithmQueryBuilder
Class: AlgorithmQueryBuilder<T>
Defined in: src/query/algorithms.ts:319
Graph algorithm query builder
Specialized query builder for graph algorithms
Extends
Type Parameters
| Type Parameter |
|---|
T extends SchemaDefinition |
Constructors
Constructor
new AlgorithmQueryBuilder<T>(
schema,
queryExecutor,
graphName): AlgorithmQueryBuilder<T>;
Defined in: src/query/algorithms.ts:327
Create a new algorithm query builder
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
schema | T | undefined | Schema definition |
queryExecutor | QueryExecutor | undefined | Query executor |
graphName | string | 'default' | Graph name |
Returns
AlgorithmQueryBuilder<T>
Overrides
AnalyticsQueryBuilder.constructor
Methods
match()
Implementation of the match method for algorithms
Call Signature
match<L>(label, alias): IMatchClause<T, L>;
Defined in: src/query/algorithms.ts:338
Add MATCH clause for a vertex
Type Parameters
| Type Parameter |
|---|
L extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
label | L |
alias | string |
Returns
IMatchClause<T, L>
Overrides
Call Signature
match<E>(
sourceAlias,
edgeLabel,
targetAlias): IEdgeMatchClause<T>;
Defined in: src/query/algorithms.ts:343
Add MATCH clause for an edge between two previously matched vertices
Type Parameters
| Type Parameter |
|---|
E extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
sourceAlias | string |
edgeLabel | E |
targetAlias | string |
Returns
IEdgeMatchClause<T>
Overrides
Call Signature
match<E>(
sourceAlias,
edgeLabel,
targetAlias,
edgeAlias): IEdgeMatchClause<T>;
Defined in: src/query/algorithms.ts:352
Add MATCH clause for an edge between two previously matched vertices with an edge alias
Type Parameters
| Type Parameter |
|---|
E extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
sourceAlias | string |
edgeLabel | E |
targetAlias | string |
edgeAlias | string |
Returns
IEdgeMatchClause<T>
Overrides
shortestPath()
shortestPath(
startAlias,
endAlias,
resultAlias,
options): this;
Defined in: src/query/algorithms.ts:405
Find the shortest path between two vertices
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
startAlias | string | undefined | Start vertex alias |
endAlias | string | undefined | End vertex alias |
resultAlias | string | 'path' | Result path alias |
options | PathFindingOptions | {} | Path finding options |
Returns
this
This algorithm query builder
allShortestPaths()
allShortestPaths(
startAlias,
endAlias,
resultAlias,
options): this;
Defined in: src/query/algorithms.ts:435
Find all shortest paths between two vertices
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
startAlias | string | undefined | Start vertex alias |
endAlias | string | undefined | End vertex alias |
resultAlias | string | 'paths' | Result paths alias |
options | PathFindingOptions | {} | Path finding options |
Returns
this
This algorithm query builder
dijkstra()
dijkstra(
startAlias,
endAlias,
costProperty,
resultAlias,
options): this;
Defined in: src/query/algorithms.ts:466
Find the shortest weighted path between two vertices using Dijkstra's algorithm
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
startAlias | string | undefined | Start vertex alias |
endAlias | string | undefined | End vertex alias |
costProperty | string | undefined | Relationship property to use as cost |
resultAlias | string | 'path' | Result path alias |
options | PathFindingOptions | {} | Path finding options |
Returns
this
This algorithm query builder
betweennessCentrality()
betweennessCentrality(
vertexAlias,
resultAlias,
options): this;
Defined in: src/query/algorithms.ts:491
Calculate betweenness centrality for vertices
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
vertexAlias | string | undefined | Vertex alias |
resultAlias | string | 'centrality' | Result alias |
options | CentralityOptions | {} | Centrality options |
Returns
this
This algorithm query builder
pageRank()
pageRank(
vertexAlias,
resultAlias,
dampingFactor,
iterations): this;
Defined in: src/query/algorithms.ts:511
Calculate PageRank for vertices
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
vertexAlias | string | undefined | Vertex alias |
resultAlias | string | 'pagerank' | Result alias |
dampingFactor | number | 0.85 | Damping factor (default: 0.85) |
iterations | number | 20 | Number of iterations (default: 20) |
Returns
this
This algorithm query builder
louvain()
louvain(
vertexAlias,
resultAlias,
options): this;
Defined in: src/query/algorithms.ts:531
Detect communities using the Louvain method
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
vertexAlias | string | undefined | Vertex alias |
resultAlias | string | 'community' | Result alias |
options | CommunityDetectionOptions | {} | Community detection options |
Returns
this
This algorithm query builder
extractNodes()
extractNodes(pathAlias, resultAlias): this;
Defined in: src/query/algorithms.ts:549
Extract nodes from a path
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
pathAlias | string | 'path' | Path alias |
resultAlias | string | 'nodes' | Result alias |
Returns
this
This algorithm query builder
extractRelationships()
extractRelationships(pathAlias, resultAlias): this;
Defined in: src/query/algorithms.ts:564
Extract relationships from a path
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
pathAlias | string | 'path' | Path alias |
resultAlias | string | 'relationships' | Result alias |
Returns
this
This algorithm query builder
pathLength()
pathLength(pathAlias, resultAlias): this;
Defined in: src/query/algorithms.ts:579
Calculate the length of a path
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
pathAlias | string | 'path' | Path alias |
resultAlias | string | 'length' | Result alias |
Returns
this
This algorithm query builder
groupBy()
groupBy(...fields): this;
Defined in: src/query/analytics.ts:398
Group results by specified fields
Parameters
| Parameter | Type | Description |
|---|---|---|
...fields | string[] | Fields to group by |
Returns
this
This analytics query builder
Throws
Error if no RETURN clause is specified before groupBy
Inherited from
windowFunction()
windowFunction(
functionType,
resultAlias,
options): this;
Defined in: src/query/analytics.ts:419
Add a window function to the query
Parameters
| Parameter | Type | Description |
|---|---|---|
functionType | string | Window function type |
resultAlias | string | Alias for the window function result |
options | WindowFunctionOptions | Window function options |
Returns
this
This analytics query builder
Inherited from
AnalyticsQueryBuilder.windowFunction
rowNumber()
rowNumber(resultAlias, options): this;
Defined in: src/query/analytics.ts:485
Add ROW_NUMBER window function
Parameters
| Parameter | Type | Description |
|---|---|---|
resultAlias | string | Alias for the result |
options | WindowFunctionOptions | Window function options |
Returns
this
This analytics query builder
Inherited from
AnalyticsQueryBuilder.rowNumber
rank()
rank(resultAlias, options): this;
Defined in: src/query/analytics.ts:496
Add RANK window function
Parameters
| Parameter | Type | Description |
|---|---|---|
resultAlias | string | Alias for the result |
options | WindowFunctionOptions | Window function options |
Returns
this
This analytics query builder
Inherited from
denseRank()
denseRank(resultAlias, options): this;
Defined in: src/query/analytics.ts:507
Add DENSE_RANK window function
Parameters
| Parameter | Type | Description |
|---|---|---|
resultAlias | string | Alias for the result |
options | WindowFunctionOptions | Window function options |
Returns
this
This analytics query builder
Inherited from
AnalyticsQueryBuilder.denseRank
where()
where(condition, params): this;
Defined in: src/query/builder.ts:234
Add WHERE clause
Parameters
| Parameter | Type | Description |
|---|---|---|
condition | string | Condition expression |
params | Record<string, any> | Parameters |
Returns
this
This query builder
Inherited from
return()
return(...expressions): this;
Defined in: src/query/builder.ts:278
Add RETURN clause
Parameters
| Parameter | Type | Description |
|---|---|---|
...expressions | string[] | Return expressions |
Returns
this
This query builder
Inherited from
orderBy()
orderBy(expression, direction): this;
Defined in: src/query/builder.ts:290
Add ORDER BY clause
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
expression | string | undefined | Expression to order by |
direction | OrderDirection | OrderDirection.ASC | Order direction |
Returns
this
This query builder
Inherited from
limit()
limit(count): this;
Defined in: src/query/builder.ts:311
Add LIMIT clause
Parameters
| Parameter | Type | Description |
|---|---|---|
count | number | Limit count |
Returns
this
This query builder
Inherited from
skip()
skip(count): this;
Defined in: src/query/builder.ts:322
Add SKIP clause
Parameters
| Parameter | Type | Description |
|---|---|---|
count | number | Skip count |
Returns
this
This query builder
Inherited from
with()
with(...expressions): this;
Defined in: src/query/builder.ts:333
Add WITH clause
Parameters
| Parameter | Type | Description |
|---|---|---|
...expressions | string[] | With expressions |
Returns
this
This query builder
Inherited from
unwind()
unwind(expression, alias): this;
Defined in: src/query/builder.ts:345
Add UNWIND clause
Parameters
| Parameter | Type | Description |
|---|---|---|
expression | string | Expression to unwind |
alias | string | Alias for unwound items |
Returns
this
This query builder
Inherited from
withParam()
withParam(name, value): this;
Defined in: src/query/builder.ts:357
Add a parameter to the query
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Parameter name |
value | any | Parameter value |
Returns
this
This query builder
Inherited from
AnalyticsQueryBuilder.withParam
setParam()
setParam(key, value): Promise<AlgorithmQueryBuilder<T>>;
Defined in: src/query/builder.ts:373
Set a parameter in the age_params temporary table
This method inserts a parameter into the age_params temporary table using an INSERT ON CONFLICT UPDATE statement. The parameter can then be referenced in a Cypher query using the get_age_param() function.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Parameter key |
value | any | Parameter value (will be converted to JSON) |
Returns
Promise<AlgorithmQueryBuilder<T>>
This query builder
Inherited from
AnalyticsQueryBuilder.setParam
withParamFunction()
withParamFunction(functionName, alias): this;
Defined in: src/query/builder.ts:398
Add a WITH clause that calls a function to get parameters
This is specifically for Apache AGE compatibility, as it requires parameters to be passed via a function call in a WITH clause.
Parameters
| Parameter | Type | Description |
|---|---|---|
functionName | string | Fully qualified function name (e.g., 'schema.get_params') |
alias | string | Alias for the function result (e.g., 'params') |
Returns
this
This query builder
Inherited from
AnalyticsQueryBuilder.withParamFunction
withAgeParam()
withAgeParam(key, alias): this;
Defined in: src/query/builder.ts:413
Add a WITH clause that calls the get_age_param function
This method adds a WITH clause that calls the get_age_param function to retrieve a parameter from the age_params temporary table.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Parameter key to retrieve |
alias | string | Alias for the parameter in the query |
Returns
this
This query builder
Inherited from
AnalyticsQueryBuilder.withAgeParam
withAllAgeParams()
withAllAgeParams(alias): this;
Defined in: src/query/builder.ts:428
Add a WITH clause that calls the get_all_age_params function
This method adds a WITH clause that calls the get_all_age_params function to retrieve all parameters from the age_params temporary table.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
alias | string | 'params' | Alias for the parameters object in the query |
Returns
this
This query builder
Inherited from
AnalyticsQueryBuilder.withAllAgeParams
execute()
execute<R>(options): QueryBuilderResult<R>;
Defined in: src/query/builder.ts:441
Execute the query
Type Parameters
| Type Parameter | Default type |
|---|---|
R | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
options | QueryExecutionOptions | Query execution options |
Returns
Query result
Throws
Error if query validation fails
Inherited from
reset()
reset(): this;
Defined in: src/query/builder.ts:584
Reset the query builder state
Returns
this
This query builder
Inherited from
toCypher()
toCypher(): string;
Defined in: src/query/builder.ts:595
Get the Cypher query string
Returns
string
Cypher query string
Inherited from
AnalyticsQueryBuilder.toCypher
getParameters()
getParameters(): Record<string, any>;
Defined in: src/query/builder.ts:607
Get the query parameters
Returns
Record<string, any>
Query parameters
Inherited from
AnalyticsQueryBuilder.getParameters
validateSchema()
validateSchema(): string[];
Defined in: src/query/builder.ts:624
Validate the query against the schema
Returns
string[]
Validation errors, if any
Inherited from
AnalyticsQueryBuilder.validateSchema
validateQuery()
validateQuery(): string[];
Defined in: src/query/builder.ts:707
Validate the query for variable references and other semantic issues
Returns
string[]
Validation errors with helpful suggestions