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.
Note
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.
KnowledgeGraphProvides access to the Knowledge Graph service data model and properties, as well as methods 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)
Allows users to add, update, and delete Entity
and Relationship
.
Note
objectid values are not supported in dictionaries for apply_edits
Parameter
Description
adds
Optional list of Entity
or Relationship
. The list of objects to add to the graph, represented in dictionary format.
updates
Optional list of Entity
or Relationship
. The list of existent graph objects that are to be updated, represented in dictionary format.
deletes
Optional list of EntityDelete
or RelationshipDelete
. The list of existent objects to remove from the graph, represented in dictionary format.
input_transform
Optional Transform
. Allows a user to specify custom quantization parameters for input geometry, which dictate how geometries are compressed and transferred to the server. Defaults to lossless WGS84 quantization.
cascade_delete
Optional boolean. When True, relationships connected to entities that are being deleted will automatically be deleted as well. When False, these relationships must be deleted manually first. Defaults to False.
cascade_delete_provenance
Optional boolean. When True, deleting entities/relationships or setting their property values to null will result in automatic deletion of associated provenance records. When False, apply_edits() will fail if there are provenance records connected to entities/relationships intended for deletion or having their properties set to null.
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import Entity, Relationship add_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)
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 as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import RelationshipExclusionRule graph.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 )
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 to be deleted, as defined in a ruleâs ânameâ attribute.
as_dict
Optional Boolean. Determines whether the result is returned as a 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)
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 as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import RelationshipExclusionRuleUpdate, ConstraintRule, ConstraintRuleMask, UpdateSetOfNamedTypes graph.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 the datamodel for the Knowledge Graph service
dict
Returns the Knowledge Graph service from an Item
Adds set of GraphProperty
to a named type in the data model
Learn more about adding properties in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type to which the properties 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 as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import GraphProperty graph.graph_property_adds(type_name="Vehicle", graph_properties=[GraphProperty(name="year")])
Delete a GraphProperty
for a named type in the data model
Learn more about deleting properties in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type containing the property to be deleted.
property_name
Required string. The property to be deleted.
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
# Delete a named type's property in the data model delete_result = knowledge_graph.graph_property_delete("Person", "Address", as_dict=False)
Adds one or more FieldIndex
to a field or multiple fields associated 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 the indexes 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 as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import FieldIndex graph.graph_property_index_adds( type_name="Person", field_indexes=[FieldIndex(name="name_index", is_ascending=True, is_unique=False, fields=["name"])], as_dict=False )
Deletes one or more FieldIndex
from fields associated 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 the field indexes from.
field_indexes
Required Sequence of strings. The field indexes to delete from the type.
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
# Delete field indexes from a Knowledge Graph type delete_result = graph.graph_property_index_deletes("Project", ["title"], as_dict=False)
Updates a GraphProperty
for a named type in the data model
Learn more about updating properties in a knowledge graph
Parameter
Description
type_name
Required string. The entity or relationship type containing the 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 as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import GraphProperty, GraphPropertyMask graph.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 )
Adds EntityType
and RelationshipType
to the data model
Learn more about adding named types to a knowledge graph
Parameter
Description
entity_types
Optional list of EntityTypes. The list of entity types to add to the data model, represented in dictionary format.
relationship_types
Optional list of RelationshipTypes. The list of relationship types to add to the data model, represented in dictionary format.
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import EntityType, RelationshipType, GraphProperty entity_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)
Deletes an EntityType
or RelationshipType
in the data model
Learn 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 as a dictionary or an object. The default is True. False is recommended.
# Delete a named type in the data model delete_result = graph.named_object_type_delete("Person")
Updates an EntityType
or RelationshipType
in the data model
Learn 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 or relationship 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 as a dictionary or an object. The default is True. False is recommended.
from arcgis.graph import EntityType, NamedObjectTypeMask type_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 the properties of the Knowledge Graph service
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 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")
List[list]
Returns the datamodel for the Knowledge Graph service
Parameter
Description
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
# Query knowledge graph data model knowledge_graph.query_data_model(as_dict=False)
Query the graph using an openCypher query. Allows for more customization than the base query()
function. Creates a generator of the query results, 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 and relationships in a graph, as well as the properties of those entities and relationships, by providing an openCypher query.
input_transform
Optional dict or Transform. Allows a user to specify custom quantization parameters for input geometry, which dictate how geometries are compressed and transferred to the server. Defaults to lossless WGS84 quantization.
bind_param
Optional dict. The bind parameters used to filter query results. Key of each pair is the string name for it, which is how the parameter can be referenced in the query. The value can be any âprimitiveâ type value that may be found as an 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 passed in as either their normal Python forms, or following the format found in Knowledge Graph entries (containing an â_objectTypeâ key, and â_propertiesâ for anonymous objects).
Note: Including bind parameters not used in the query will cause queries to yield nothing on ArangoDB based services, while Neo4j based services will still produce results.
include_provenance
Optional boolean. When True, provenance entities (metadata) will be included in the query results. Defaults to False.
# Get a list of all query results query_gen = knowledge_graph.query_streaming("MATCH path = (n)-[r]-(n2) RETURN path LIMIT 5") results = list(gen) # Grab one result at a time query_gen = knowledge_graph.query_streaming("MATCH path = (n)-[r]-(n2) RETURN path LIMIT 5") first_result = next(query_gen) second_result = next(query_gen)
Generator[Sequence[Any], None, None]
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 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, both_entity_relationship, and meta_entity_provenance. Both and both_entity_relationship are functionally the same.
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
#Perform a search on the knowledge graph for search_result in knowledge_graph.search("cat", as_dict=False): print(search_result) # Perform a search on only entities in the knowledge graph for searchentities_result in knowledge_graph.search("cat", "entities", as_dict=False): print(searchentities_result)
Generator[Sequence[Any], None, None]
Synchronizes the Knowledge Graph Serviceâs data model with any changes made in the database. Will return any errors or warnings from the sync.
Parameter
Description
as_dict
Optional Boolean. Determines whether the result is returned as a dictionary or an object. The default is True. False is recommended.
# Synchronize the data model sync_result = knowledge_graph.sync_data_model(as_dict=False)
Allows users to add or delete SearchIndexProperties
for different EntityType
and RelationshipType
from the GraphDataModel
. Can only be existent properties for a given entity/relationship type.
from arcgis.graph import SearchIndexProperties graph.update_search_index( adds={"Person": SearchIndexProperties(property_names=["name"])}, as_dict=False )
Represents an constraint rule to define how data can be created in the 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
Optional esriGraphConstraintRuleRole. The default value is âesriGraphConstraintRuleRoleRegularâ..
from arcgis.graph import ConstraintRule # Example 1: Update a constraint rule person_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 model data_model = graph.query_data_model() data_model.constraint_rules
The constraint rule alias.
Whether the constraint rule is disabled.
The constraint rule name.
The constraint rule role.
The constraint rule type.
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.
from arcgis.graph import ConstraintRuleMask ConstraintRuleMask(update_name=True, update_alias=True, update_disabled=True)
Whether to update the alias in the constraint rule.
Whether to update if the constraint rule is disabled.
Whether to update the name in the constraint rule.
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.
from arcgis.graph import EndPoint EndPoint("Person", "Company")
The destination entity type for the relationship type.
The origin entity type for the relationship type.
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
Optional esriGraphNamedObjectRole 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 {}.
from arcgis.graph import EntityType # Example 1: Define an entity type EntityType( 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 model data_model = graph.query_data_model() data_model.entity_types['Person'].properties
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.
from arcgis.graph import FieldIndex # Example 1: create a FieldIndex to use FieldIndex(name="name_index", is_ascending=True, is_unique=False, fields=["name"]) # Example 2: access FieldIndex in the data model data_model = graph.query_data_model() data_model.entity_types["Person"].field_indexes['name_index'].fields
The list of fields participating in the index.
Whether the index is ascending.
Whether the index is unique.
The index name.
Convert a snake_case string to camelCase.
snake: The string to convert.
The converted camelCase string.
Allows users to access information about the knowledge graphâs data model.
from arcgis.gis import GIS from arcgis.graph import KnowledgeGraph, GraphDataModel graph = 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 strict data_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 values data_model.provenance_source_type_values # Access the constraint rules data_model.constraint_rules
Whether the Knowledge Graph is ArcGIS managed.
The list of constraint rules.
The timestamp of the last change to the data model.
The list of entity types in the data model.
The name of the GlobalID property.
Contains information about the unique identifier.
The list of meta entity types in the data model.
The name of the ObjectID property.
The Provenance source type values.
The list of relationship types in the data model.
The list of search indexes.
The spatial reference of the Knowledge Graph.
If True, the data model can only be edited by admins or owners.
Represents a property of an EntityType
or RelationshipType
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
Optional esriFieldType string. The default value is âesriFieldTypeStringâ.
geometry_type
Optional esriGeometryType 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
Optional esriGraphPropertyRole string. The default value is âesriGraphPropertyRegularâ.
from arcgis.graph import GraphProperty # Example 1: simple string property GraphProperty(name="name", alias="name", required=True) # Example 2: geometry property GraphProperty(name="shape", field_type="esriFieldTypeGeoemtry", geometry_type="esriGeometryPolygon") # Example 3: get GraphProperty information from data model data_model = graph.query_data_model() data_model.entity_types['Person'].properties['name'].required # accesses the required property on the GraphProperty 'name'.
The alias of the property.
The default property value, or None if there is no default.
The domain of the property.
Whether the property is editable.
The type of the property.
The geometry type, or None if not a geometry property.
Whether the geometry has M values.
Whether the geometry has Z values.
Whether the property is system maintained.
The name of the property.
Whether the property is nullable.
Whether the property is required.
The role of the property.
Whether the property is visible.
Convert a snake_case string to camelCase.
snake: The string to convert.
The converted camelCase string.
Allows users to define which settings should be updated for a GraphProperty
during a graph_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.
from arcgis.graph import GraphPropertyMask GraphPropertyMask(update_name=True, update_visible=True, update_editable=True)
Whether to update the property alias.
Whether to update the property default value.
Whether to update the property domain.
Whether to update if the property is editable.
Whether to update the property field type.
Whether to update the property geometry type.
Whether to update if the property has M values.
Whether to update if the property has Z values.
Whether to update the property name.
Whether to update if the property is nullable.
Whether to update if the property is required.
Whether to update if the property is visible.
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.
from arcgis.graph import NamedObjectTypeMask NamedObjectTypeMask(update_name=True, update_alias=True, update_strict=True)
Whether to update the alias in the entity or relationship type.
Whether to update the name in the entity or relationship type.
Whether to update the role in the entity or relationship type.
Whether to update if the entity or relationship type is strict.
Represents an exclusion rule to define how relationships can be created in the 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
Optional esriGraphConstraintRuleRole. The default value is âesriGraphConstraintRuleRoleRegularâ.
origin_entity_types
Required SetOfNamedTypes
.
relationship_types
Required SetOfNamedTypes
.
destination_entity_types
Required SetOfNamedTypes
.
from arcgis.graph import RelationshipExclusionRule, SetOfNamedTypes # Example 1: Define an exclusion rule RelationshipExclusionRule( 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 model data_model = graph.query_data_model() data_model.constraint_rules
The destination entity types in the rule.
The origin entity types in the rule.
The relationship types in the rule.
The constraint rule type.
Allows a user to provide information for updating a relationship exclusion rule
from arcgis.graph import RelationshipExclusionRuleUpdate, RelationshipExclusionRule, ConstraintRuleMask RelationshipExclusionRuleUpdate( 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=[]) )
Updates to the set of destination entity types.
Updates to the set of origin entity types.
Updates to the set of relationship types.
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
Optional esriGraphNamedObjectRole 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 [].
from arcgis.graph import RelationshipType # Example 1: Define a relationship type RelationshipType( 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 model data_model = graph.query_data_model() data_model.relationship_types['WorksAt'].properties
The observed origin and destination entity type pairs in the database for the relationship type.
Allows users to define the set of named types for a RelationshipExclusionRule
.
Defining a set will exclude the set of named type names from being created in the graph once the exclusion rule is applied. Defining a set_complement will exclude anything other than the set of named type names from 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 [].
from arcgis.graph import SetOfNamedTypes # Example 1: set SetOfNamedTypes(set=["Person","Animal"]) # Example 2: set_complement SetOfNamedTypes(set_complement=["Company"])
The set of types.
The complement of the set of types.
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.
from arcgis.graph import UpdateSetOfNamedTypes UpdateSetOfNamedTypes(add_named_types=["Individual"], remove_named_types=["Person"])
The named types to add to the set.
The named types to remove from the set.
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 will be assigned to the entity when it is created.
properties
Required Dictionary of Strings and Any values. String is the property name and Any value is the value for that property.
from arcgis.graph import Entity # Example 1: Define an entity Entity( type_name="Company", properties={"name":"Esri"} ) # Example 2: Access an entity in a query response query_result = graph.query("MATCH (n) RETURN n") next(query_result)[0].properties
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.
from arcgis.graph import EntityDelete # Example 1: Provide entity id values manually EntityDelete(type_name="Person", ids=[UUID("783bd422-3hfp-45c7-87aa-8adbbdac0a3d")]) # Example 2: Delete from results of a query results = graph.query("MATCH (n:Person) WHERE n.name CONTAINS "delete" RETURN n.globalid") EntityDelete(type_name="Person", ids=list(results)[0])
A list of Entity
and Relationship
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 path path.path[1] # first relationship in path path.path[-1] # last entity in path
The list of entities and relationships in the path.
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 will be 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 property name and Any value is the value for that property.
from arcgis.graph import Relationship from datetime import datetime from uuid import UUID # Example 1: Define a relationship Relationship( 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 response query_result = graph.query("MATCH ()-[n]-() RETURN n") next(query_result)[0].properties
The unique identifier of the relationshipâs destination entity.
The unique identifier of the relationshipâs origin entity.
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.
from arcgis.graph import RelationshipDelete # Example 1: Provide relationship id values manually RelationshipDelete(type_name="WorksAt", ids=[UUID("783bd422-3hfp-45c7-87aa-8adbbdac0a3d")]) # Example 2: Delete from results of a query results = graph.query("MATCH ()-[n:WorksAt]-() WHERE n.name CONTAINS "delete" RETURN n.globalid") RelationshipDelete(type_name="WorksAt", ids=list(results)[0])
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.
The M false origin.
The M resolution.
The X false origin.
The XY resolution.
The Y false origin.
The Z false origin.
The Z resolution.
Convert a snake_case string to camelCase.
snake: The string to convert.
The converted camelCase string.
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
The list of search analyzers.
The name of the search index.
The search properties, grouped by type name.
The supported category of the search index.
List of properties for search index
Parameter
Description
property_names
Required List of Strings. Names of properties.
from arcgis.graph import SearchIndexProperties SearchIndexProperties(property_names=["name","comment"])
The properties in the search index.
Response for applying edits to Entity
or Relationship
in the graph.
# Example of a response without errors ApplyEditsResponse( 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 errors ApplyEditsResponse( 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=[] )
The cascade deleted relationships, grouped by type name.
The cascade deleted Provenance entities.
The edit results, grouped by type name.
The error, or None if the operation was successful.
The relationship type schema changes, grouped by type name.
Convert a snake_case string to camelCase.
snake: The string to convert.
The converted camelCase string.
Response for adding a RelationshipExclusionRule
constraint rule.
# Example of successful add result ConstraintRuleAddsResponse( error=None, constraint_rule_add_results=[ ConstraintRuleAddResult( name='PersonCanOnlyWorkAtCompany', error=None, warnings=[] ) ] ) # Example of a response with errors ConstraintRuleAddsResponse( 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=[] ) ] )
The list of results for the added constraint rules.
The error, or None if the operation was successful.
Response for deleting a RelationshipExclusionRule
.
# Example of a response without errors ConstraintRuleDeletesResponse( error=None, constraint_rule_delete_results=[ ConstraintRuleDeleteResult(name='PersonCanOnlyWorkAtCompany', error=None) ] ) # Example of a response with errors ConstraintRuleDeletesResponse( 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." ) ) ] )
The list of results from deleting the constraint rules.
The error, or None if the operation was successful.
Response for updating a RelationshipExclusionRule
.
# Example of a response without errors ConstraintRuleUpdatesResponse( error=None, constraint_rule_update_results=[ ConstraintRuleUpdateResult( name='PersonCanOnlyWorkAtCompany', error=None, warnings=[] ) ] ) # Example of a response with errors ConstraintRuleUpdatesResponse( 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].' ) ] ) ] )
The list of results from updating the constraint rule.
The error, or None if the operation was successful.
Response for adding a FieldIndex
to a GraphProperty
.
# Example of a successful response IndexAddsResponse( error=None, index_add_results=[ IndexAddResult( name='name_index', error=None ) ] ) # Example of a response with errors IndexAddsResponse( error=None, index_add_results=[ IndexAddResult( name='name_index', error=Error( error_code=112047, error_message="Graph Index, 'name_index', already exists." ) ) ] )
The error, or None if the operation was successful.
The list of results for the added indexes.
Response for deleting a FieldIndex
from a GraphProperty
.
# Example of a successful response IndexDeletesResponse( error=None, index_delete_results=[ IndexDeleteResult( name='name_index', error=None ) ] ) # Example of a response with errors IndexDeletesResponse( 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." ) ) ] )
The error, or None if the operation was successful.
The list of results for the deleted indexes.
Response for adding a named object type to the graph.
# Example of a successful response NamedObjectTypeAddsResponse( error=None, entity_add_results=[ NamedObjectTypeAddResult( name='Vehicle', error=None ) ], relationship_add_results=[ NamedObjectTypeAddResult( name='Drives', error=None ) ] ) # Example of a response with errors NamedObjectTypeAddsResponse( 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." ) ) ] )
The list of results for added entity types.
The error, or None if the operation was successful.
The list of results for added relationship types.
Convert a snake_case string to camelCase.
snake: The string to convert.
The converted camelCase string.
Response for updating a named object type in the graph.
# Example of a successful response NamedObjectTypeUpdateResponse(error=None) # Example of a response with errors NamedObjectTypeUpdateResponse( error=Error( error_code=112075, error_message='Updating the name of an entity or relationship type is not allowed.' ) )
The error, or None if the operation was successful.
Response for deleting a named object type in the graph.
# Example of a successful response NamedObjectTypeDeleteResponse(error=None) # Example of a response with errors NamedObjectTypeDeleteResponse( error=Error( error_code=112020, error_message="The entity or relationship type definition, 'Vehicle', was not found." ) )
The error, or None if the operation was successful.
Response for adding a GraphProperty
to an EntityType
or RelationshipType
in the graph.
# Example of a successful response PropertyAddsResponse( error=None, property_add_results=[ PropertyAddResult( name='age', error=None ) ] ) # Example of a response with errors PropertyAddsResponse( error=None, property_add_results=[ PropertyAddResult( name='age', error=Error( error_code=112043, error_message="Graph property, 'age', already exists in data model." ) ) ] )
The error, or None if the operation was successful.
The list of results for the added properties.
Convert a snake_case string to camelCase.
snake: The string to convert.
The converted camelCase string.
Response for updating a GraphProperty
in the graph.
# Example of a successful response PropertyUpdateResponse(error=None) # Example of a response with errors PropertyUpdateResponse(error=Error(error_code=112068, error_message="Graph property, 'current_age', does not exist in data model."))
The error, or None if the operation was successful.
Response for deleting a GraphProperty
in the graph.
# Example of a successful response PropertyDeleteResponse(error=None) # Example of a response with errors PropertyDeleteResponse(error=Error(error_code=112068, error_message="Graph property, 'age', does not exist in data model."))
The error, or None if the operation was successful.
Response for syncing the GraphDataModel
using sync_data_model()
.
# Example of a successful response SyncDataModelResponse(error=None) # Example of a response with errors SyncDataModelResponse( error=Error( error_code=113005, error_message="The service's graph data source does not support the operation." ) )
The error, or None if the operation was successful.
The list of results for each named type.
The list of warnings returned for the operation.
Response for updating a SearchIndex
using update_search_index()
.
# Example of a successful response UpdateSearchIndexResponse(error=None) # Example of a response with errors UpdateSearchIndexResponse( error=Error( error_code=112093, error_message="The entity or relationship type, 'NotAType', does not exist." ) )
The error, or None if the operation was successful.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4