Skip to content

Knowledge graph functions are only available when using a knowledge graph service. The following functions allow you to access and query knowledge graphs.


KnowledgeGraphByPortalItem

KnowledgeGraphByPortalItem(portalObject, itemId) -> KnowledgeGraph

Since version 1.26

Function bundle: Knowledge Graph

Returns a knowledge graph from a portal item.

Parameters

  • portalObject: Portal - The Portal from which to query features.
  • itemId: Text - The GUID of the portal item referencing a knowledge graph service. This value must be a text literal.

Return value: KnowledgeGraph

Additional resources

Example

Returns the knowledge graph from the portal item.

Use dark colors for code blocksCopy
1 2 3 4 var knowledgeGraph = KnowledgeGraphByPortalItem(  Portal('https://www.example.com/arcgis'), // enterprise portal  '7b1fb95ab77f40bf8aa09c8b59045449', );

QueryGraph

QueryGraph(graph, openCypherQuery, queryParameters?, includeProvenance?) -> Array

Since version 1.26

Function bundle: Knowledge Graph

Queries a knowledge graph with an openCypher query and returns the set of entities and relationships in a graph, along with their properties.

Parameters

  • graph: KnowledgeGraph - The knowledge graph to query.
  • openCypherQuery: Text - The openCypher query to be executed against the knowledge graph.
  • queryParameters (Optional): Dictionary - A dictionary of named query parameters for the openCypher query. The parameter names or keys in the dictionary are case-sensitive. Parameters accepted depend on the external graph store and can be of type: Array, Date, Dictionary, Geometry, Number, Text
  • includeProvenance (Optional): Boolean - Since 1.31 Indicates whether to include provenance entities (metadata) in the query results. Default is false.

Return value: Array

Additional resources

Examples

Queries the knowledge graph for information about the Student entities it contains.

Use dark colors for code blocksCopy
1 2 3 4 5 6 7 8 var results = QueryGraph(  knowledgeGraph,  'MATCH (p:Student)-[e:EnrolledAt]->(s:School)  WHERE s.name = "Eastside Elementary"  RETURN p,e,s.principal,s.numStaff  LIMIT 1');  return Text(results);

Queries the knowledge graph using bind parameters.

Use dark colors for code blocksCopy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 // searches for entities with a `name` property that matches the given string in the query parameters // OR falls within the given geom bounding box // query returns both the supplier and the part that it buys var query = `MATCH (s:Supplier)-[:buys_part]-(p:Part)  WHERE s.name=$name OR esri.graph.ST_Intersects($geom, s.geometry)  RETURN s,p`;   var results = QueryGraph(  $graph,  query,  {  "name": "Supplier 1",  "geom": Polygon({  rings: [[  [38,-78],  [39,-79],  [39,-76],  [-38,-76],  [-38,-78]  ]]  })  }  );

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.