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.
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
# Connect to a Knowledge Graph service: gis = GIS(url="url",username="username",password="password") knowledge_graph = KnowledgeGraph(url, gis=gis)
Returns the datamodel for the Knowledge Graph service
Returns the Knowledge Graph service from an Item
Returns the properties of the Knowledge Graph service
Queries the Knowledge Graph using openCypher
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")
Allows for the searching of the properties of entities, relationships, or both in the graph using a full-text index.
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 = knowledge_graph.search("cat") # Perform a search on only entities in the knowledge graph searchentities_result = knowledge_graph.search("cat", "entities")