arcgis.graph module

The arcgis.graph module contains classes and functions for working with ArcGIS Knowledge graphs. The available functions allow for searching and querying the graph data, and viewing the data model of the graph database.

Knowledge graphs consist of entities and the relationships between them, each of which can contain properties which describe their attributes. The data model of the knowledge graph can show you which entities, relationships, and properties are in your database, along with other information about the graph. Performing a search or openCypher query on the graph will return results from the database based on the search or query terms provided.


Applications based on ArcGIS API for Python version 2.0.1 can only communicate with knowledge graphs in an ArcGIS Enterprise 10.9.1 or 11.0 deployment. ArcGIS Enterprise 11.1 includes breaking changes for knowledge graphs. Only applications based on ArcGIS API for Python version 2.1.0 or later will be able to communicate with knowledge graphs in an Enterprise 11.1 deployment. See the ArcGIS Enterprise Knowledge Server documentation for more details.


class arcgis.graph.KnowledgeGraph(url, *, gis=None)

Provides access to the Knowledge Graph service data model and properties, as well as methods to search and query the graph.




Knowledge Graph service URL


an authenticated arcigs.gis.GIS object.

# Connect to a Knowledge Graph service:

gis = GIS(url="url",username="username",password="password")

knowledge_graph = KnowledgeGraph(url, gis=gis)
property datamodel

Returns the datamodel for the Knowledge Graph service

classmethod fromitem(item)

Returns the Knowledge Graph service from an Item

property properties

Returns the properties of the Knowledge Graph service


Queries the Knowledge Graph using openCypher

Learn more about querying a knowledge graph




Required String. Allows you to return the entities and relationships in a graph, as well as the properties of those entities and relationships, by providing an openCypher query.

# Perform an openCypher query on the knowledge graph
query_result = knowledge_graph.query("MATCH path = (n)-[r]-(n2) RETURN path LIMIT 5")


search(search, category='both')

Allows for the searching of the properties of entities, relationships, or both in the graph using a full-text index.

Learn more about searching a knowledge graph




Required String. The search to perform on the Knowledge Graph.


Optional String. The category is the location of the full text search. This can be isolated to either the entities or the relationships. The default is to look in both.

The allowed values are: both, entities, relationships


Check the service definition for the Knowledge Graph service for valid values of category. Not all services support both.

#Perform a search on the knowledge graph
search_result ="cat")

# Perform a search on only entities in the knowledge graph
searchentities_result ="cat", "entities")


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