arcgis.graph module
Thearcgis.graph
module contains classes and functions for working with ArcGIS Knowledge graphs. The availablefunctions 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 describetheir attributes. The data model of the knowledge graph can show you which entities, relationships, and properties are inyour database, along with other information about the graph. Performing a search or openCypher query on the graph willreturn results from the database based on the search or query terms provided.
Note
Applications based on ArcGIS API for Python version 2.0.1 can only communicate with knowledge graphs in an ArcGIS Enterprise10.9.1 or 11.0 deployment. ArcGIS Enterprise 11.1 includes breaking changes for knowledge graphs. Only applications based onArcGIS 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
- classarcgis.graph.KnowledgeGraph(url:str,*,gis=None)
Provides access to the Knowledge Graph service data model and properties, as well asmethods to search and query the graph.
Parameter
Description
url
Knowledge Graph service URL
gis
an authenticated
GIS
object.# Connect to a Knowledge Graph service:gis=GIS(url="url",username="username",password="password")knowledge_graph=KnowledgeGraph(url,gis=gis)
- apply_edits(adds:Sequence[dict[str,Any]|Entity|Relationship]=[],updates:Sequence[dict[str,Any]|Entity|Relationship]=[],deletes:Sequence[dict[str,Any]|EntityDelete|RelationshipDelete]=[],input_transform:dict[str,Any]|Transform|None=None,cascade_delete:bool=False,cascade_delete_provenance:bool=False,as_dict:bool=True)→dict|ApplyEditsResponse
Allows users to add, update, and delete
Entity
andRelationship
.Note
objectid values are not supported in dictionaries for apply_edits
Parameter
Description
adds
Optional list of
Entity
orRelationship
. The list ofobjects to add to the graph, represented in dictionary format.updates
Optional list of
Entity
orRelationship
. The list ofexistent graph objects that are to be updated, representedin dictionary format.deletes
Optional list of
EntityDelete
orRelationshipDelete
. The listof existent objects to remove from the graph, represented indictionary format.input_transform
Optional
Transform
.Allows a user to specify custom quantization parameters for inputgeometry, which dictate how geometries are compressed andtransferred to the server. Defaults to lossless WGS84 quantization.cascade_delete
Optional boolean. WhenTrue, relationships connected toentities that are being deleted will automatically be deletedas well. WhenFalse, these relationships must be deletedmanually first. Defaults toFalse.
cascade_delete_provenance
Optional boolean. WhenTrue, deleting entities/relationshipsor setting their property values to null will result inautomatic deletion of associated provenance records. WhenFalse,apply_edits() will fail if there are provenancerecords connected to entities/relationships intended fordeletion or having their properties set to null.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportEntity,Relationshipadd_entity=Entity(type_name="Company",properties={"name":"Esri"})delete_relationship=DeleteRelationship(type_name="WorksAt",ids=[UUID("783bd422-3hfp-45c7-87aa-8adbbdac0a3d")])graph.apply_edits(adds=[add_entity],deletes=[delete_relationship],as_dict=False)
- Returns:
- constraint_rule_adds(rules:Sequence[dict[str,Any]|ConstraintRule],as_dict:bool=True)→dict|ConstraintRuleAddsResponse
Adds constraint rules for entities & relationships to the data model.
RelationshipExclusionRule
is a constraint rule.Parameter
Description
rules
Required Sequence of
RelationshipExclusionRule
.Defines the constraint rules to be added.as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportRelationshipExclusionRulegraph.constraint_rule_adds(rules=[RelationshipExclusionRule(name="OnlyPersonCanWorkAtCompany",origin_entity_types=SetOfNamedTypes(set_complement=["Person"]),relationship_types=SetOfNamedTypes(set=["WorksAt"]),destination_entity_types=SetOfNamedTypes(set=["Company"]))],as_dict=False)
- Returns:
- constraint_rule_deletes(rule_names:Sequence[str],as_dict:bool=True)→dict|ConstraintRuleDeletesResponse
Deletes existing constraint rules for entities & relationships from the data model.
RelationshipExclusionRule
is a constraint rule.Parameter
Description
rule_names
Required Sequence of strings. The names of the constraint rules tobe deleted, as defined in a rule’s ‘name’ attribute.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
# Delete a constraint rule from the Knowledge Graph's data model.graph.constraint_rule_deletes(["constraint_rule_1"],as_dict=False)
- Returns:
- constraint_rule_updates(rules:Sequence[dict[str,Any]|ConstraintRuleUpdate],as_dict:bool=True)→dict|ConstraintRuleUpdatesResponse
Update
ConstraintRule
for entities & relationships in the data model.RelationshipExclusionRule
is a type of constraint rule.Parameter
Description
rules
Required Sequence of
RelationshipExclusionRuleUpdate
.Defines the constraint rules to be updated.as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportRelationshipExclusionRuleUpdate,ConstraintRule,ConstraintRuleMask,UpdateSetOfNamedTypesgraph.constraint_rule_updates(rules=[RelationshipExclusionRuleUpdate(rule_name="OnlyPersonCanWorkForCompany",mask=ConstraintRuleMask(update_name=True,update_alias=True),constraint_rule=ConstraintRule(name="PersonCanWorkForCompanyOrPark",alias="Person Can Work For Company or Park"))],as_dict=False)
- Returns:
- graph_property_adds(type_name:str,graph_properties:Sequence[dict[str,Any]|GraphProperty],as_dict:bool=True)→dict|PropertyAddsResponse
Adds set of
GraphProperty
to a named type in the data modelLearn more about adding properties in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type to which theproperties will be added.
graph_properties
Required Sequence of
GraphProperty
.The Sequence of properties to add to the named type.as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportGraphPropertygraph.graph_property_adds(type_name="Vehicle",graph_properties=[GraphProperty(name="year")])
- Returns:
- graph_property_delete(type_name:str,property_name:str,as_dict:bool=True)→dict|PropertyDeleteResponse
Delete a
GraphProperty
for a named type in the data modelLearn more about deleting properties in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type containingthe property to be deleted.
property_name
Required string. The property to be deleted.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
# Delete a named type's property in the data modeldelete_result=knowledge_graph.graph_property_delete("Person","Address",as_dict=False)
- Returns:
- graph_property_index_adds(type_name:str,field_indexes:Sequence[dict[str,Any]|FieldIndex],as_dict:bool=True)→dict|IndexAddsResponse
Adds one or more
FieldIndex
to a field or multiple fieldsassociated with a named type in the data model.Learn more about adding graph property indexes in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type to add theindexes to.
field_indexes
Required list of dicts. The indexes to add for the type.See below for an example of the structure.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportFieldIndexgraph.graph_property_index_adds(type_name="Person",field_indexes=[FieldIndex(name="name_index",is_ascending=True,is_unique=False,fields=["name"])],as_dict=False)
- Returns:
- graph_property_index_deletes(type_name:str,field_indexes:Sequence[str],as_dict:bool=True)→dict|IndexDeletesResponse
Deletes one or more
FieldIndex
from fieldsassociated with a named type in the data model.Learn more about deleting graph property indexes from a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type to delete thefield indexes from.
field_indexes
Required Sequence of strings. The field indexes to delete from thetype.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
# Delete field indexes from a Knowledge Graph typedelete_result=graph.graph_property_index_deletes("Project",["title"],as_dict=False)
- Returns:
- graph_property_update(type_name:str,property_name:str,graph_property:dict[str,Any]|GraphProperty,mask:dict[str,Any]|GraphPropertyMask,as_dict:bool=True)→dict|PropertyUpdateResponse
Updates a
GraphProperty
for a named type in the data modelLearn more about updating properties in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type containingthe property to be updated.
property_name
Required string. The property to be updated.
graph_property
Required
GraphProperty
.The graph property to be updated.mask
Required
GraphPropertyMask
.The properties of the field to be updated.as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportGraphProperty,GraphPropertyMaskgraph.graph_property_update(type_name="Vehicle",property_name="year",graph_property=GraphProperty(name="year",alias="year_made"),mask=GraphPropertyMask(update_alias=True),as_dict=False)
- Returns:
- named_object_type_adds(entity_types:Sequence[dict[str,Any]|EntityType]=[],relationship_types:Sequence[dict[str,Any]|RelationshipType]=[],as_dict:bool=True)→dict|NamedObjectTypeAddsResponse
Adds
EntityType
andRelationshipType
to the data modelLearn more about adding named types to a knowledge graph
Parameter
Description
entity_types
Optional list of EntityTypes. The list of entity typesto add to the data model, represented in dictionary format.
relationship_types
Optional list of RelationshipTypes. The list ofrelationship types to add to the data model, represented indictionary format.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportEntityType,RelationshipType,GraphPropertyentity_type_add=EntityType(name="Vehicle",properties={"make":GraphProperty(name="make")})relationship_type_add=RelationshipType(name="Drives")graph.named_object_type_adds(entity_types=[entity_type_add],relationship_types=[relationship_type_add],as_dict=False)
- Returns:
- named_object_type_delete(type_name:str,as_dict:bool=True)→dict|NamedObjectTypeDeleteResponse
Deletes an
EntityType
orRelationshipType
in the data modelLearn more about deleting named types in a knowledge graph
Parameter
Description
type_name
Required string. The named type to be deleted.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
# Delete a named type in the data modeldelete_result=graph.named_object_type_delete("Person")
- Returns:
- named_object_type_update(type_name:str,named_type_update:dict[str,Any]|EntityType|RelationshipType,mask:dict[str,Any]|NamedObjectTypeMask,as_dict:bool=True)→dict|NamedObjectTypeUpdateResponse
Updates an
EntityType
orRelationshipType
in the data modelLearn more about updating named types in a knowledge graph
Parameter
Description
type_name
Required string. The named type to be updated.
named_type_update
Required Union[
EntityType
,RelationshipType
]. The entity orrelationship type to be updated.mask
Required
NamedObjectTypeMask
.The properties of the named type to be updated.as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
fromarcgis.graphimportEntityType,NamedObjectTypeMasktype_update=EntityType(name="Vehicle",alias="Car")graph.named_object_type_update(type_name="Vehicle",named_type_update=type_update,mask=NamedObjectTypeMask(update_alias=True),as_dict=False)
- Returns:
- query(query:str)→List[dict]
Deprecated since version 2.4.1:Removed in: 3.0.0. Use query_streaming instead.
Deprecated since version 2.4.1:Removed in: 3.0.0. Use query_streaming instead.
Queries the Knowledge Graph using openCypher
Learn more about querying a knowledge graph
Parameter
Description
query
Required String. Allows you to return the entities andrelationships in a graph, as well as the properties of thoseentities and relationships, by providing an openCypher query.
# Perform an openCypher query on the knowledge graphquery_result=knowledge_graph.query("MATCH path = (n)-[r]-(n2) RETURN path LIMIT 5")
- Returns:
List[list]
- query_data_model(as_dict:bool=True)→dict|GraphDataModel
Returns the datamodel for the Knowledge Graph service
Parameter
Description
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
# Query knowledge graph data modelknowledge_graph.query_data_model(as_dict=False)
- Returns:
- query_streaming(query:str,input_transform:dict[str,Any]|Transform|None=None,bind_param:dict[str,Any]={},include_provenance:bool=False,as_dict:bool=True)→Generator[Sequence[Any],None,None]
Query the graph using an openCypher query. Allows for more customization than the base
query()
function. Creates a generator of the queryresults, from which users can access each row or add them to a list.See below for example usage.Parameter
Description
query
Required String. Allows you to return the entities andrelationships in a graph, as well as the properties of thoseentities and relationships, by providing an openCypher query.
input_transform
Optional dict or Transform. Allows a user to specify custom quantizationparameters for input geometry, which dictate how geometries arecompressed and transferred to the server. Defaults to losslessWGS84 quantization.
bind_param
Optional dict. The bind parameters used to filterquery results. Key of each pair is the string name for it,which is how the parameter can be referenced in the query. Thevalue can be any “primitive” type value that may be found asan attribute of an entity or relationship (e.g., string,double, boolean, etc.), a list, an anonymous object (a dict),or a geometry.
Anonymous objects and geometries can be passedin as either their normal Python forms, or following theformat found in Knowledge Graph entries (containing an“_objectType” key, and “_properties” for anonymous objects).
Note: Including bind parameters not used in the query willcause queries to yield nothing on ArangoDB based services,while Neo4j based services will still produce results.
include_provenance
Optional boolean. WhenTrue, provenance entities (metadata)will be included in the query results. Defaults toFalse.
# Get a list of all query resultsquery_gen=knowledge_graph.query_streaming("MATCH path = (n)-[r]-(n2) RETURN path LIMIT 5")results=list(gen)# Grab one result at a timequery_gen=knowledge_graph.query_streaming("MATCH path = (n)-[r]-(n2) RETURN path LIMIT 5")first_result=next(query_gen)second_result=next(query_gen)
- Returns:
Generator[Sequence[Any], None, None]
- search(search:str,category:str='both',as_dict:bool=True)→List[Sequence[Any]]
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
Parameter
Description
search
Required String. The search to perform on the Knowledge Graph.
category
Optional String. The category is the location of the fulltext search. This can be isolated to either theentities ortherelationships. The default is to look inboth.
The allowed values are: both, entities, relationships,both_entity_relationship, and meta_entity_provenance. Both andboth_entity_relationship are functionally the same.
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
Note
Check theservice definition for the Knowledge Graph servicefor valid values of category. Not all services support both and both_entity_relationship.
#Perform a search on the knowledge graphforsearch_resultinknowledge_graph.search("cat",as_dict=False):print(search_result)# Perform a search on only entities in the knowledge graphforsearchentities_resultinknowledge_graph.search("cat","entities",as_dict=False):print(searchentities_result)
- Returns:
Generator[Sequence[Any], None, None]
- sync_data_model(as_dict:bool=True)→dict|SyncDataModelResponse
Synchronizes the Knowledge Graph Service’s data model with any changes madein the database. Will return any errors or warnings from the sync.
Parameter
Description
as_dict
Optional Boolean. Determines whether the result is returned asa dictionary or an object. The default is True. False is recommended.
# Synchronize the data modelsync_result=knowledge_graph.sync_data_model(as_dict=False)
- Returns:
- update_search_index(adds:dict[str,dict|SearchIndexProperties]={},deletes:dict[str,dict|SearchIndexProperties]={},as_dict:bool=True)→dict|UpdateSearchIndexResponse
Allows users to add or delete
SearchIndexProperties
for differentEntityType
andRelationshipType
from theGraphDataModel
. Can only be existent properties for a givenentity/relationship type.fromarcgis.graphimportSearchIndexPropertiesgraph.update_search_index(adds={"Person":SearchIndexProperties(property_names=["name"])},as_dict=False)
- Returns:
Data Model Types
ConstraintRule
- pydanticmodelarcgis.graph.data_model_types.ConstraintRule
Represents an constraint rule to define how data can be created inthe knowledge graph.
Parameter
Description
name
Required String. Name for the exclusion rule.
alias
Optional String. The default value is “”.
disabled
Optional Boolean. The default value is False.
role
OptionalesriGraphConstraintRuleRole. The default value is “esriGraphConstraintRuleRoleRegular”..
fromarcgis.graphimportConstraintRule# Example 1: Update a constraint ruleperson_company_constraint=ConstraintRule(name="PersonCanWorkForCompanyOrPark",alias="Person Can Work For Company or Park")graph.constraint_rule_updates(rules=[RelationshipExclusionRuleUpdate(rule_name="OnlyPersonCanWorkForCompany",mask=ConstraintRuleMask(update_name=True,update_alias=True),constraint_rule=person_company_constraint)],as_dict=False)# Example 2: Access an exclusion rule from the data modeldata_model=graph.query_data_model()data_model.constraint_rules
- fieldrole:Literal['esriGraphConstraintRuleRoleUNSPECIFIED','esriGraphConstraintRuleRoleRegular','esriGraphConstraintRuleRoleHasDocument','esriGraphConstraintRuleRoleNoProvenanceOrigin','esriGraphConstraintRuleRoleNoProvenanceDestination']='esriGraphConstraintRuleRoleRegular'
The constraint rule role.
ConstraintRuleMask
- pydanticmodelarcgis.graph.data_model_types.ConstraintRuleMask
Allows users to define which settings to update for a contraint rule
Parameter
Description
update_name
Optional Boolean. The default value is False.
update_alias
Optional Boolean. The default value is False.
update_disabled
Optional Boolean. The default value is False.
fromarcgis.graphimportConstraintRuleMaskConstraintRuleMask(update_name=True,update_alias=True,update_disabled=True)
EndPoint
- pydanticmodelarcgis.graph.data_model_types.EndPoint
Represents a set of origin and destination entity types for a relationship type
Parameter
Description
origin_enity_type
Required String. Name of origin entity type.
destination_entity_type
Required String. Name of destination entity type.
fromarcgis.graphimportEndPointEndPoint("Person","Company")
EntityType
- pydanticmodelarcgis.graph.data_model_types.EntityType
Represents an entity named object type for a Knowledge Graph.
Parameter
Description
name
Required String. Name for the Entity Type.
alias
Optional String. The default value is “”.
role
OptionalesriGraphNamedObjectRole String. The default value is “esriGraphNamedObjectRegular”.
strict
Optional Boolean. The default value is False.
properties
Optional Dict(String,
GraphProperty
). The default value is {}.field_indexes
Optional Dict(String,
FieldIndex
). The default value is {}.fromarcgis.graphimportEntityType# Example 1: Define an entity typeEntityType(name="Person",properties={"name":GraphProperty(name="name")},field_indexes={"name_index":FieldIndex(name="name_index",is_ascending=True,is_unique=False,fields=["name"])})# Example 2: Access information about an entity type from the data modeldata_model=graph.query_data_model()data_model.entity_types['Person'].properties
FieldIndex
- pydanticmodelarcgis.graph.data_model_types.FieldIndex
Represents a field index to be used in
graph_property_index_adds()
.Parameter
Description
name
Required String. Name for the field index.
is_ascending
Required Boolean.
is_unique
Required Boolean.
fields
Required List(String). List of field names for the index.
fromarcgis.graphimportFieldIndex# Example 1: create a FieldIndex to useFieldIndex(name="name_index",is_ascending=True,is_unique=False,fields=["name"])# Example 2: access FieldIndex in the data modeldata_model=graph.query_data_model()data_model.entity_types["Person"].field_indexes['name_index'].fields
GraphDataModel
- pydanticmodelarcgis.graph.data_model_types.GraphDataModel
Allows users to access information about the knowledge graph’s data model.
fromarcgis.gisimportGISfromarcgis.graphimportKnowledgeGraph,GraphDataModelgraph=KnowledgeGraph("URL to Knowledge Graph Service",gis=GIS("home"))data_model=graph.query_data_model()# Access the timestamp the data model was last update. The response will be an integer timestamp.data_model.data_model_timestamp# Access the spatial reference. The response will be a dictionary containing the spatial reference information.data_model.spatial_reference# Access entity types. The response will be a dictionary of string names and EntityType objects.data_model.entity_types# Access relationship types. The response will be a dictionary of string names and RelationshipType objects.data_model.relationship_types# Access meta entity types (example: Provenance). The response will be a dictionary of string names and EntityType objects.data_model.meta_entity_types# Access the boolean value of whether the data model is strictdata_model.strict# Access the object id property name. The response will be a string.data_model.objectid_property# Access the global id property name. The response will be a string.data_model.globalid_property# Access the boolean value of whether the knowledge graph is ArcGIS managed.data_model.arcgis_managed# Access the identifier info. The response will be a IdentifierInfo object.data_model.identifier_info# Access the search indexes. The response will be a list of SearchIndex objects.data_model.search_indexes# Access the provenance source type valuesdata_model.provenance_source_type_values# Access the constraint rulesdata_model.constraint_rules
- fieldconstraint_rules:list[Annotated[ConstraintRule|RelationshipExclusionRule,Discriminator(discriminator=type,custom_error_type=None,custom_error_message=None,custom_error_context=None)]]=[]
The list of constraint rules.
- fieldentity_types:list[EntityType]=[]
The list of entity types in the data model.
- fieldmeta_entity_types:list[EntityType]=[]
The list of meta entity types in the data model.
- fieldprovenance_source_type_values:ProvenanceSourceTypeValues=ProvenanceSourceTypeValues(value_behavior_array=[])
The Provenance source type values.
- fieldrelationship_types:list[RelationshipType]=[]
The list of relationship types in the data model.
- fieldsearch_indexes:list[SearchIndex]=[]
The list of search indexes.
GraphProperty
- pydanticmodelarcgis.graph.data_model_types.GraphProperty
Represents a property of an
EntityType
orRelationshipType
in the Knowledge Graph.Parameter
Description
name
Required String. Name for the property. The default value is “”.
alias
Optional String. Alias for the property. The default value is “”.
domain
Optional String. Name of domain for the property. The default value is “”.
field_type
OptionalesriFieldType string. The default value is “esriFieldTypeString”.
geometry_type
OptionalesriGeometryType string. The default is None.
has_z
Optional Boolean. The default value is False.
has_m
Optional Boolean. The default value is False.
default_value
Optional Any value. The default value is None.
nullable
Optional Boolean. The default value is True.
visible
Optional Boolean. The default value is True.
editable
Optional Boolean. The default value is True.
required
Optional Boolean. The default value is False.
role
OptionalesriGraphPropertyRole string. The default value is “esriGraphPropertyRegular”.
fromarcgis.graphimportGraphProperty# Example 1: simple string propertyGraphProperty(name="name",alias="name",required=True)# Example 2: geometry propertyGraphProperty(name="shape",field_type="esriFieldTypeGeoemtry",geometry_type="esriGeometryPolygon")# Example 3: get GraphProperty information from data modeldata_model=graph.query_data_model()data_model.entity_types['Person'].properties['name'].required# accesses the required property on the GraphProperty 'name'.
- fieldfield_type:Literal['esriFieldTypeSmallInteger','esriFieldTypeInteger','esriFieldTypeSingle','esriFieldTypeDouble','esriFieldTypeString','esriFieldTypeDate','esriFieldTypeDateOnly','esriFieldTypeTimeOnly','esriFieldTypeTimestampOffset','esriFieldTypeOID','esriFieldTypeGeometry','esriFieldTypeBlob','esriFieldTypeRaster','esriFieldTypeGUID','esriFieldTypeGlobalID','esriFieldTypeXML','esriFieldTypeBigInteger']='esriFieldTypeString'
The type of the property.
- fieldgeometry_type:Literal['esriGeometryPoint','esriGeometryMultipoint','esriGeometryPolyline','esriGeometryPolygon','esriGeometryEnvelope']|None=None
The geometry type, or None if not a geometry property.
- fieldrole:Literal['esriGraphPropertyUNSPECIFIED','esriGraphPropertyRegular','esriGraphPropertyDocumentName','esriGraphPropertyDocumentTitle','esriGraphPropertyDocumentUrl','esriGraphPropertyDocumentText','esriGraphPropertyDocumentKeywords','esriGraphPropertyDocumentContentType','esriGraphPropertyDocumentMetadata','esriGraphPropertyDocumentFileExtension','esriGraphPropertyProvenanceInstanceId','esriGraphPropertyProvenanceSourceType','esriGraphPropertyProvenanceSourceName','esriGraphPropertyProvenanceSource','esriGraphPropertyProvenanceComment','esriGraphPropertyProvenanceTypeName','esriGraphPropertyProvenancePropertyName']='esriGraphPropertyRegular'
The role of the property.
GraphPropertyMask
- pydanticmodelarcgis.graph.data_model_types.GraphPropertyMask
Allows users to define which settings should be updated for a
GraphProperty
during agraph_property_update()
.Parameter
Description
update_name
Optional Boolean. The default value is False.
update_alias
Optional Boolean. The default value is False.
update_domain
Optional Boolean. The default value is False.
update_field_type
Optional Boolean. The default value is False.
update_geometry_type
Optional Boolean. The default value is False.
update_has_z
Optional Boolean. The default value is False.
update_has_m
Optional Boolean. The default value is False.
update_default_value
Optional Boolean. The default value is False.
update_nullable
Optional Boolean. The default value is False.
update_visible
Optional Boolean. The default value is False.
update_editable
Optional Boolean. The default value is False.
update_required
Optional Boolean. The default value is False.
fromarcgis.graphimportGraphPropertyMaskGraphPropertyMask(update_name=True,update_visible=True,update_editable=True)
NamedObjectTypeMask
- pydanticmodelarcgis.graph.data_model_types.NamedObjectTypeMask
Allows user to define what should be updated when performing a
named_object_type_update()
.Parameter
Description
update_name
Optional Boolean. The default value is False.
update_alias
Optional Boolean. The default value is False.
update_role
Optional Boolean. The default value is False.
update_strict
Optional Boolean. The default value is False.
fromarcgis.graphimportNamedObjectTypeMaskNamedObjectTypeMask(update_name=True,update_alias=True,update_strict=True)
RelationshipExclusionRule
- pydanticmodelarcgis.graph.data_model_types.RelationshipExclusionRule
Represents an exclusion rule to define how relationships can be created inthe knowledge graph between defined entity types.
Parameter
Description
name
Required String. Name for the exclusion rule.
alias
Optional String. The default value is “”.
disabled
Optional Boolean. The default value is False.
role
OptionalesriGraphConstraintRuleRole. The default value is “esriGraphConstraintRuleRoleRegular”.
origin_entity_types
Required
SetOfNamedTypes
.relationship_types
Required
SetOfNamedTypes
.destination_entity_types
Required
SetOfNamedTypes
.fromarcgis.graphimportRelationshipExclusionRule,SetOfNamedTypes# Example 1: Define an exclusion ruleRelationshipExclusionRule(name="OnlyPersonCanWorkAtCompany",origin_entity_types=SetOfNamedTypes(set_complement=["Person"]),relationship_types=SetOfNamedTypes(set=["WorksAt"]),destination_entity_types=SetOfNamedTypes(set=["Company"]))# Example 2: Access an exclusion rule from the data modeldata_model=graph.query_data_model()data_model.constraint_rules
- fielddestination_entity_types:SetOfNamedTypes[Required]
The destination entity types in the rule.
- fieldorigin_entity_types:SetOfNamedTypes[Required]
The origin entity types in the rule.
- fieldrelationship_types:SetOfNamedTypes[Required]
The relationship types in the rule.
RelationshipExclusionRuleUpdate
- pydanticmodelarcgis.graph.data_model_types.RelationshipExclusionRuleUpdate
Allows a user to provide information for updating a relationship exclusion rule
Parameter
Description
rule_name
Required String. Name of the constraint rule to update
mask
Required
ConstraintRuleMask
.constraint_rule
Required
RelationshipExclusionRule
.update_origin_entity_types
Required
UpdateSetOfNamedTypes
.update_relationship_types
Required
UpdateSetOfNamedTypes
.update_destination_entity_types
Required
UpdateSetOfNamedTypes
.fromarcgis.graphimportRelationshipExclusionRuleUpdate,RelationshipExclusionRule,ConstraintRuleMaskRelationshipExclusionRuleUpdate(rule_name="OnlyPersonCanWorkForCompany",mask=ConstraintRuleMask(update_name=True,update_alias=True),constraint_rule=RelationshipExclusionRule(name="PersonCanOnlyWorkAtCompany",alais="Person Works At Company",origin_entity_types=SetOfNamedTypes(set_complement=["Person"]),relationship_types=SetOfNamedTypes(set=["WorksAt"]),destination_entity_types=SetOfNamedTypes(set=["Company"])),update_origin_entity_types=UpdateSetOfNamedTypes(add_named_types=["Employee"],remove_named_types=[]),update_relationship_types=UpdateSetOfNamedTypes(add_named_types=["WorksFor"],remove_named_types=["WorksAt"]),update_destination_entity_types=UpdateSetOfNamedTypes(add_named_types=["Park"],remove_named_types=[]))
- fieldupdate_destination_entity_types:UpdateSetOfNamedTypes[Required]
Updates to the set of destination entity types.
- fieldupdate_origin_entity_types:UpdateSetOfNamedTypes[Required]
Updates to the set of origin entity types.
- fieldupdate_relationship_types:UpdateSetOfNamedTypes[Required]
Updates to the set of relationship types.
RelationshipType
- pydanticmodelarcgis.graph.data_model_types.RelationshipType
Represents a relationship named object type for a Knowledge Graph.
Parameter
Description
name
Required String. Name for the Entity Type.
alias
Optional String. The default value is “”.
role
OptionalesriGraphNamedObjectRole String. The default value is “esriGraphNamedObjectRegular”.
strict
Optional Boolean. The default value is False.
properties
Optional Dict(String,
GraphProperty
). The default value is {}.field_indexes
Optional Dict(String,
FieldIndex
). The default value is {}.end_points
Optional List[
EndPoint
]. The default value is [].fromarcgis.graphimportRelationshipType# Example 1: Define a relationship typeRelationshipType(name="WorksAt",properties={"name":GraphProperty(name="name")},field_indexes={"name_index":FieldIndex(name="name_index",is_ascending=True,is_unique=False,fields=["name"])})# Example 2: Access a relationship type from the data modeldata_model=graph.query_data_model()data_model.relationship_types['WorksAt'].properties
- fieldobserved_end_points:list[EndPoint]=[]
The observed origin and destination entity type pairs in the database for the relationship type.
SetOfNamedTypes
- pydanticmodelarcgis.graph.data_model_types.SetOfNamedTypes
Allows users to define the set of named types for a
RelationshipExclusionRule
.Defining aset will exclude the set of named type names from being created in the graphonce the exclusion rule is applied.Defining aset_complement will exclude anything other than the set of named type namesfrom being created in the graph once the exclusion rule is applied.
Parameter
Description
set
Optional List of Strings. The default value is [].
set_complement
Optional List of Strings. The default value is [].
fromarcgis.graphimportSetOfNamedTypes# Example 1: setSetOfNamedTypes(set=["Person","Animal"])# Example 2: set_complementSetOfNamedTypes(set_complement=["Company"])
UpdateSetOfNamedTypes
- pydanticmodelarcgis.graph.data_model_types.UpdateSetOfNamedTypes
Allows a user to define named types to add or remove from a
RelationshipExclusionRule
.Parameter
Description
add_named_types
Required List of Strings. Names of types to add to rule.
remove_named_types
Required List of Strings. Names of types to remove from rule.
fromarcgis.graphimportUpdateSetOfNamedTypesUpdateSetOfNamedTypes(add_named_types=["Individual"],remove_named_types=["Person"])
Graph Types
Entity
- pydanticmodelarcgis.graph.graph_types.Entity
Represents an entity instance in the knowledge graph
Parameter
Description
type_name
Required String. Name of the
EntityType
id
Optional UUID. The default value is None. If not provided, an id willbe assigned to the entity when it is created.
properties
Required Dictionary of Strings and Any values. String is the propertyname and Any value is the value for that property.
fromarcgis.graphimportEntity# Example 1: Define an entityEntity(type_name="Company",properties={"name":"Esri"})# Example 2: Access an entity in a query responsequery_result=graph.query("MATCH (n) RETURN n")next(query_result)[0].properties
EntityDelete
- pydanticmodelarcgis.graph.graph_types.EntityDelete
Allows a user to define which entities to delete from a
EntityType
.Parameter
Description
type_name
Required String. Name of the
EntityType
ids
Required List of UUID or Strings. Ids of the entities to delete.
fromarcgis.graphimportEntityDelete# Example 1: Provide entity id values manuallyEntityDelete(type_name="Person",ids=[UUID("783bd422-3hfp-45c7-87aa-8adbbdac0a3d")])# Example 2: Delete from results of a queryresults=graph.query("MATCH (n:Person) WHERE n.name CONTAINS "delete" RETURN n.globalid")EntityDelete(type_name="Person",ids=list(results)[0])
Path
- pydanticmodelarcgis.graph.graph_types.Path
A list of
Entity
andRelationship
objects required to traverse a graph from one entity to another.graph.query("MATCH path=()-[]-() RETURN path LIMIT 1")path=list(result)[0][0]path.path[0]# first entity in pathpath.path[1]# first relationship in pathpath.path[-1]# last entity in path
- fieldpath:list[Entity|Relationship][Required]
The list of entities and relationships in the path.
Relationship
- pydanticmodelarcgis.graph.graph_types.Relationship
Represents a relationship instance in the knowledge graph
Parameter
Description
type_name
Required String. Name of the
EntityType
id
Optional UUID or String. The default value is None. If not provided, an id willbe assigned to the entity when it is created.
origin_entity_id
Required UUID or String. The id of the origin
Entity
in the graph.destiation_entity_id
Required UUID or String. The id of the destination
Entity
in the graph.properties
Optional Dictionary of Strings and Any values. String is the propertyname and Any value is the value for that property.
fromarcgis.graphimportRelationshipfromdatetimeimportdatetimefromuuidimportUUID# Example 1: Define a relationshipRelationship(type_name="WorksAt",origin_entity_id=UUID("488bd414-3afd-4547-89aa-4adbbdac0a8d"),destination_entity_id=UUID("783bd422-3hfp-45c7-87aa-8adbbdac0a3d"),properties={"start_date":datetime.fromtimestamp(1578247200000)})# Example 2: Access an relationship in a query responsequery_result=graph.query("MATCH ()-[n]-() RETURN n")next(query_result)[0].properties
RelationshipDelete
- pydanticmodelarcgis.graph.graph_types.RelationshipDelete
Allows a user to define which relationships to delete from a
RelationshipType
.Parameter
Description
type_name
Required String. Name of the
RelationshipType
ids
Required List of UUID or Strings. Ids of the relationships to delete.
fromarcgis.graphimportRelationshipDelete# Example 1: Provide relationship id values manuallyRelationshipDelete(type_name="WorksAt",ids=[UUID("783bd422-3hfp-45c7-87aa-8adbbdac0a3d")])# Example 2: Delete from results of a queryresults=graph.query("MATCH ()-[n:WorksAt]-() WHERE n.name CONTAINS "delete" RETURN n.globalid")RelationshipDelete(type_name="WorksAt",ids=list(results)[0])
Transform
- pydanticmodelarcgis.graph.graph_types.Transform
Allows a user to specify custom quantization parameters for input geometry,which dictate how geometries are compressed and transferred to the server.
Parameter
Description
xy_resolution
Required float.
x_false_origin
Required float.
y_false_origin
Required float.
z_resolution
Required float.
z_false_origin
Required float.
m_resolution
Required float.
m_false_origin
Required float.
Search Types
SearchIndex
- pydanticmodelarcgis.graph.search_types.SearchIndex
Allows full-text search capability on the graph for a set of properties for each entity or relationship type.Search indexes can be accessed in the
GraphDataModel
.data_model=graph.query_data_model()data_model.search_indexes
- fieldsearch_properties:dict[str,SearchIndexProperties][Required]
The search properties, grouped by type name.
SearchIndexProperties
Response Types
ApplyEditsResponse
- pydanticmodelarcgis.graph.response_types.ApplyEditsResponse
Response for applying edits to
Entity
orRelationship
in the graph.# Example of a response without errorsApplyEditsResponse(error=None,edits_result={'Person':EditResults(add_results=[EditResult(id=UUID('ab913bcb-1781-4137-9513-b3c942c23bc2'),error=None)],update_results=[],delete_results=[]),'Company':EditResults(add_results=[EditResult(id=UUID('26419c98-5521-4611-b2c2-196c35acc06d'),error=None)],update_results=[],delete_results=[]),'WorksAt':EditResults(add_results=[EditResult(id=UUID('1da2f6fc-e407-4561-97db-bba4745bd803'),error=None)],update_results=[],delete_results=[])},cascaded_deletes={},relationship_schema_changes={},cascaded_provenance_deletes=[])# Example of a response with errorsApplyEditsResponse(error=Error(error_code=111188,error_message="The destination identifier '{6F445050-0037-4308-8EE4-4B52C83763DC}' was not found."),edits_result={},cascaded_deletes={},relationship_schema_changes={},cascaded_provenance_deletes=[])
- fieldcascaded_deletes:dict[str,list[CascadingRelationshipDelete]][Required]
The cascade deleted relationships, grouped by type name.
- fieldcascaded_provenance_deletes:list[CascadingProvenanceDelete]=[]
The cascade deleted Provenance entities.
- fieldrelationship_schema_changes:dict[str,RelationshipTypeSchemaChanges][Required]
The relationship type schema changes, grouped by type name.
ConstraintRuleAddsResponse
- pydanticmodelarcgis.graph.response_types.ConstraintRuleAddsResponse
Response for adding a
RelationshipExclusionRule
constraint rule.# Example of successful add resultConstraintRuleAddsResponse(error=None,constraint_rule_add_results=[ConstraintRuleAddResult(name='PersonCanOnlyWorkAtCompany',error=None,warnings=[])])# Example of a response with errorsConstraintRuleAddsResponse(error=None,constraint_rule_add_results=[ConstraintRuleAddResult(name='PersonCanOnlyWorkAtCompany',error=Error(error_code=112237,error_message="Error adding the constraint rule, 'PersonCanOnlyWorkAtCompany', to the data model."),warnings=[])])
ConstraintRuleDeletesResponse
- pydanticmodelarcgis.graph.response_types.ConstraintRuleDeletesResponse
Response for deleting a
RelationshipExclusionRule
.# Example of a response without errorsConstraintRuleDeletesResponse(error=None,constraint_rule_delete_results=[ConstraintRuleDeleteResult(name='PersonCanOnlyWorkAtCompany',error=None)])# Example of a response with errorsConstraintRuleDeletesResponse(error=None,constraint_rule_delete_results=[ConstraintRuleDeleteResult(name='PersonCanOnlyWorkAtCompany2',error=Error(error_code=112242,error_message="The constraint rule 'PersonCanOnlyWorkAtCompany2' with role 'REGULAR' does not exist in the data model."))])
ConstraintRuleUpdatesResponse
- pydanticmodelarcgis.graph.response_types.ConstraintRuleUpdatesResponse
Response for updating a
RelationshipExclusionRule
.# Example of a response without errorsConstraintRuleUpdatesResponse(error=None,constraint_rule_update_results=[ConstraintRuleUpdateResult(name='PersonCanOnlyWorkAtCompany',error=None,warnings=[])])# Example of a response with errorsConstraintRuleUpdatesResponse(error=None,constraint_rule_update_results=[ConstraintRuleUpdateResult(name='PersonCanOnlyWorkAtCompany',error=None,warnings=[Error(error_code=112225,error_message="A relationship with origin entity type 'Employee', relationship type 'WorksFor', and destination entity type 'Park' is explicitly allowed by relationship exclusion rule 'PersonCanOnlyWorkAtCompany', but not allowed by relationship exclusion rule 'PersonCanOnlyWorkAtCompany3'."),Error(error_code=112244,error_message='The following entity types do not exist in the data model: [Employee, Park].'),Error(error_code=112245,error_message='The following relationship types do not exist in the data model: [WorksFor].')])])
IndexAddsResponse
- pydanticmodelarcgis.graph.response_types.IndexAddsResponse
Response for adding a
FieldIndex
to aGraphProperty
.# Example of a successful responseIndexAddsResponse(error=None,index_add_results=[IndexAddResult(name='name_index',error=None)])# Example of a response with errorsIndexAddsResponse(error=None,index_add_results=[IndexAddResult(name='name_index',error=Error(error_code=112047,error_message="Graph Index, 'name_index', already exists."))])
IndexDeletesResponse
- pydanticmodelarcgis.graph.response_types.IndexDeletesResponse
Response for deleting a
FieldIndex
from aGraphProperty
.# Example of a successful responseIndexDeletesResponse(error=None,index_delete_results=[IndexDeleteResult(name='name_index',error=None)])# Example of a response with errorsIndexDeletesResponse(error=None,index_delete_results=[IndexDeleteResult(name='name_index',error=Error(error_code=112051,error_message="Graph Index, 'name_index', does not exist in the data model."))])
NamedObjectTypeAddsResponse
- pydanticmodelarcgis.graph.response_types.NamedObjectTypeAddsResponse
Response for adding a named object type to the graph.
# Example of a successful responseNamedObjectTypeAddsResponse(error=None,entity_add_results=[NamedObjectTypeAddResult(name='Vehicle',error=None)],relationship_add_results=[NamedObjectTypeAddResult(name='Drives',error=None)])# Example of a response with errorsNamedObjectTypeAddsResponse(error=None,entity_add_results=[NamedObjectTypeAddResult(name='Vehicle',error=Error(error_code=112092,error_message="The entity or relationship type, 'Vehicle', already exists, please provide a new type name."))],relationship_add_results=[NamedObjectTypeAddResult(name='Drives',error=Error(error_code=112092,error_message="The entity or relationship type, 'Drives', already exists, please provide a new type name."))])
- fieldentity_add_results:list[NamedObjectTypeAddResult][Required]
The list of results for added entity types.
- fieldrelationship_add_results:list[NamedObjectTypeAddResult][Required]
The list of results for added relationship types.
NamedObjectTypeUpdateResponse
- pydanticmodelarcgis.graph.response_types.NamedObjectTypeUpdateResponse
Response for updating a named object type in the graph.
# Example of a successful responseNamedObjectTypeUpdateResponse(error=None)# Example of a response with errorsNamedObjectTypeUpdateResponse(error=Error(error_code=112075,error_message='Updating the name of an entity or relationship type is not allowed.'))
NamedObjectTypeDeleteResponse
- pydanticmodelarcgis.graph.response_types.NamedObjectTypeDeleteResponse
Response for deleting a named object type in the graph.
# Example of a successful responseNamedObjectTypeDeleteResponse(error=None)# Example of a response with errorsNamedObjectTypeDeleteResponse(error=Error(error_code=112020,error_message="The entity or relationship type definition, 'Vehicle', was not found."))
PropertyAddsResponse
- pydanticmodelarcgis.graph.response_types.PropertyAddsResponse
Response for adding a
GraphProperty
to anEntityType
orRelationshipType
in the graph.# Example of a successful responsePropertyAddsResponse(error=None,property_add_results=[PropertyAddResult(name='age',error=None)])# Example of a response with errorsPropertyAddsResponse(error=None,property_add_results=[PropertyAddResult(name='age',error=Error(error_code=112043,error_message="Graph property, 'age', already exists in data model."))])
- fieldproperty_add_results:list[PropertyAddResult][Required]
The list of results for the added properties.
PropertyUpdateResponse
- pydanticmodelarcgis.graph.response_types.PropertyUpdateResponse
Response for updating a
GraphProperty
in the graph.# Example of a successful responsePropertyUpdateResponse(error=None)# Example of a response with errorsPropertyUpdateResponse(error=Error(error_code=112068,error_message="Graph property, 'current_age', does not exist in data model."))
PropertyDeleteResponse
- pydanticmodelarcgis.graph.response_types.PropertyDeleteResponse
Response for deleting a
GraphProperty
in the graph.# Example of a successful responsePropertyDeleteResponse(error=None)# Example of a response with errorsPropertyDeleteResponse(error=Error(error_code=112068,error_message="Graph property, 'age', does not exist in data model."))
SyncDataModelResponse
- pydanticmodelarcgis.graph.response_types.SyncDataModelResponse
Response for syncing the
GraphDataModel
usingsync_data_model()
.# Example of a successful responseSyncDataModelResponse(error=None)# Example of a response with errorsSyncDataModelResponse(error=Error(error_code=113005,error_message="The service's graph data source does not support the operation."))
UpdateSearchIndexResponse
- pydanticmodelarcgis.graph.response_types.UpdateSearchIndexResponse
Response for updating a
SearchIndex
usingupdate_search_index()
.# Example of a successful responseUpdateSearchIndexResponse(error=None)# Example of a response with errorsUpdateSearchIndexResponse(error=Error(error_code=112093,error_message="The entity or relationship type, 'NotAType', does not exist."))