Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"source": [
"## Connect\n",
"\n",
"Using the ArcGIS API for Python, you can connect to a `KnowledgeGraph` with `arcgis.graph`:"
"Using the ArcGIS API for Python, you can connect to a [`KnowledgeGraph`](https://developers.arcgis.com/python/latest/api-reference/arcgis.graph.html#knowledgegraph) with [`arcgis.graph`](https://developers.arcgis.com/python/latest/api-reference/arcgis.graph.html):"
]
},
{
Expand Down Expand Up @@ -90,7 +90,7 @@
"metadata": {},
"source": [
"## Create\n",
"Using the ArcGIS API for Python, you can create a new Knowledge Graph using [create_service()](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.create_service)."
"Using the ArcGIS API for Python, you can create a new Knowledge Graph using [`create_service()`](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.create_service)."
]
},
{
Expand Down Expand Up @@ -166,143 +166,73 @@
"metadata": {},
"outputs": [],
"source": [
"knowledge_graph.datamodel"
"knowledge_graph.query_data_model(as_dict=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The response from `datamodel` has many useful components that describe the schema of the knowledge graph. Important information to look for on the data model includes spatial reference, strictness, whether the service is arcgis managed, information on the unique identifier property, and search indexes. The data model also includes detailed information on each entity and relationship type.\n",
"The response from `query_data_model()` has many useful components that describe the schema of the knowledge graph. When `as_dict` is set to `False`, the response will be a `GraphDataModel`. Important information to look for on the data model includes spatial reference, strictness, whether the service is arcgis managed, information on the unique identifier property, and search indexes. The data model also includes detailed information on each entity and relationship type.\n",
"\n",
"```\n",
"{'data_model_timestamp': datetime.datetime(2023, 3, 22, 14, 4, 44, 432000),\n",
" 'spatial_reference': {'wkid': 4326},\n",
" 'entity_types': <dictionary of entity types>, # see below for more info on type dictionaries\n",
" 'relationship_types': <dictionary of relationship types>, # see below for more info on type dictionaries\n",
" 'strict': False,\n",
" 'objectid_property': 'objectid',\n",
" 'globalid_property': 'globalid',\n",
" 'arcgis_managed': True,\n",
" 'identifier_info': {'identifier_mapping_info': {'uniform_property': {'identifier_property_name': 'globalid'}},\n",
" 'identifier_generation_info': {'uuid_method_hint': 'esriUUIDESRI'}},\n",
" 'search_indexes': {'esri__search_idx': {'name': 'esri__search_idx',\n",
" 'supported_category': 'Both',\n",
" 'analyzers': [{'name': 'text_en'}, {'name': 'identity'}],\n",
" 'search_properties': {'Document': {'property_names': ['metadata',\n",
" 'keywords',\n",
" 'fileExtension',\n",
" 'globalid',\n",
" 'name',\n",
" 'text',\n",
" 'title',\n",
" 'contentType',\n",
" 'url']},\n",
" 'HasDocument': {'property_names': ['globalid']},\n",
" 'Observation': {'property_names': ['quality_grade',\n",
" 'globalid',\n",
" 'time_observed',\n",
" 'description',\n",
" 'location',\n",
" 'observation_url',\n",
" 'photo_url',\n",
" 'species_guess',\n",
" 'most_disagree_with_identificati',\n",
" 'place_guess']},\n",
" 'Observed': {'property_names': ['globalid']},\n",
" 'ObservedIn': {'property_names': ['globalid']},\n",
" 'Reviewed': {'property_names': ['globalid']},\n",
" 'Species': {'property_names': ['taxon_common_name',\n",
" 'globalid',\n",
" 'taxon_name',\n",
" 'taxon_wikipedia',\n",
" 'taxon_photo_url']},\n",
" 'User': {'property_names': ['globalid', 'name', 'created_date']}}}}}\n",
"GraphDataModel(\n",
" data_model_timestamp=1737573982389, \n",
" spatial_reference={'wkid': 4326}, \n",
" entity_types=[\n",
" EntityType(\n",
" name='Vehicle', \n",
" alias='', \n",
" role='esriGraphNamedObjectRegular', \n",
" strict=False, \n",
" properties=[\n",
" GraphProperty(name='objectid', alias='objectid', domain='', field_type='esriFieldTypeOID', geometry_type=None, has_z=False, has_m=False, default_value=None, nullable=False, visible=True, editable=False, required=True, is_system_maintained=True, role='esriGraphPropertyRegular'), \n",
" GraphProperty(name='globalid', alias='globalid', domain='', field_type='esriFieldTypeGlobalID', geometry_type=None, has_z=False, has_m=False, default_value=None, nullable=False, visible=True, editable=False, required=True, is_system_maintained=True, role='esriGraphPropertyRegular'), \n",
" GraphProperty(name='make', alias='', domain='', field_type='esriFieldTypeString', geometry_type=None, has_z=False, has_m=False, default_value=None, nullable=True, visible=True, editable=True, required=False, is_system_maintained=False, role='esriGraphPropertyRegular')\n",
" ], \n",
" field_indexes=[\n",
" FieldIndex(name='esri__oid_idx', is_ascending=True, is_unique=True, fields=['objectid']), \n",
" FieldIndex(name='esri__globalid_idx', is_ascending=True, is_unique=True, fields=['globalid'])\n",
" ]\n",
" )\n",
" ],\n",
" search_indexes=[\n",
" SearchIndex(\n",
" name='esri__search_idx', \n",
" supported_category='both_entity_relationship', \n",
" analyzers=[SearchAnalyzer(name='text_en'), \n",
" SearchAnalyzer(name='identity')], \n",
" search_properties={\n",
" 'Document': SearchIndexProperties(property_names=['metadata', 'keywords', 'fileExtension', 'globalid', 'name', 'text', 'title', 'contentType', 'url']), \n",
" 'HasDocument': SearchIndexProperties(property_names=['globalid']), \n",
" 'Vehicle': SearchIndexProperties(property_names=['globalid', 'make'])\n",
" }\n",
" )\n",
" ], \n",
" provenance_source_type_values=ProvenanceSourceTypeValues(value_behavior_array=[]), \n",
" constraint_rules=[\n",
" RelationshipExclusionRule(name='HasDocumentRule', alias=\"Relationships of type 'HasDocument' can only have a destination entity of type 'Document'.\", disabled=False, role='esriGraphConstraintRuleRoleHasDocument', type='esriGraphRelationshipExclusionRuleType', origin_entity_types=SetOfNamedTypes(set=[], set_complement=[]), relationship_types=SetOfNamedTypes(set=['HasDocument'], set_complement=[]), destination_entity_types=SetOfNamedTypes(set=[], set_complement=['Document']))\n",
" ]\n",
")\n",
"```\n",
"\n",
"Entity and relationship types each have a format very similar to each other including basic information about the type like the name, role and strictness as well as properties and field indexes on the type. For a single type, this could look like:\n",
"```\n",
"{'Company': {\n",
" 'name': 'Company',\n",
" 'alias': '',\n",
" 'role': 'esriGraphNamedObjectRegular',\n",
" 'strict': False,\n",
" 'properties': {\n",
" 'name': {\n",
" 'name': 'name',\n",
" 'alias': 'name',\n",
" 'fieldType': 'esriFieldTypeString',\n",
" 'hasZ': False,\n",
" 'hasM': False,\n",
" 'nullable': True,\n",
" 'editable': True,\n",
" 'visible': True,\n",
" 'required': False,\n",
" 'isSystemMaintained': False,\n",
" 'role': 'esriGraphPropertyRegular'\n",
" },\n",
" 'objectid': {\n",
" 'name': 'objectid',\n",
" 'alias': 'objectid',\n",
" 'fieldType': 'esriFieldTypeOID',\n",
" 'hasZ': False,\n",
" 'hasM': False,\n",
" 'nullable': False,\n",
" 'editable': False,\n",
" 'visible': True,\n",
" 'required': True,\n",
" 'isSystemMaintained': True,\n",
" 'role': 'esriGraphPropertyRegular'\n",
" },\n",
" 'globalid': {\n",
" 'name': 'globalid',\n",
" 'alias': 'globalid',\n",
" 'fieldType': 'esriFieldTypeGlobalID',\n",
" 'hasZ': False,\n",
" 'hasM': False,\n",
" 'nullable': False,\n",
" 'editable': False,\n",
" 'visible': True,\n",
" 'required': True,\n",
" 'isSystemMaintained': True,\n",
" 'role': 'esriGraphPropertyRegular'\n",
" },\n",
" 'shape': {\n",
" 'name': 'shape',\n",
" 'alias': 'shape',\n",
" 'fieldType': 'esriFieldTypeGeometry',\n",
" 'geometryType': 'esriGeometryPoint',\n",
" 'hasZ': False,\n",
" 'hasM': False,\n",
" 'nullable': True,\n",
" 'editable': True,\n",
" 'visible': True,\n",
" 'required': False,\n",
" 'isSystemMaintained': False,\n",
" 'role': 'esriGraphPropertyRegular'\n",
" }\n",
" },\n",
" 'field_indexes': {\n",
" 'esri__oid_idx': {\n",
" 'name': 'esri__oid_idx',\n",
" 'fields': ['objectid'],\n",
" 'isAscending': True,\n",
" 'isUnique': True\n",
" },\n",
" 'esri__globalid_idx': {\n",
" 'name': 'esri__globalid_idx',\n",
" 'fields': ['globalid'],\n",
" 'isAscending': True,\n",
" 'isUnique': True\n",
" },\n",
" 'esri__shape_geo_idx': {\n",
" 'name': 'esri__shape_geo_idx',\n",
" 'fields': ['shape'],\n",
" 'isAscending': True,\n",
" 'isUnique': False\n",
" }\n",
" }\n",
"}\n",
"EntityType(\n",
" name='Vehicle', \n",
" alias='', \n",
" role='esriGraphNamedObjectRegular', \n",
" strict=False, \n",
" properties=[\n",
" GraphProperty(name='objectid', alias='objectid', domain='', field_type='esriFieldTypeOID', geometry_type=None, has_z=False, has_m=False, default_value=None, nullable=False, visible=True, editable=False, required=True, is_system_maintained=True, role='esriGraphPropertyRegular'), \n",
" GraphProperty(name='globalid', alias='globalid', domain='', field_type='esriFieldTypeGlobalID', geometry_type=None, has_z=False, has_m=False, default_value=None, nullable=False, visible=True, editable=False, required=True, is_system_maintained=True, role='esriGraphPropertyRegular'), \n",
" GraphProperty(name='make', alias='', domain='', field_type='esriFieldTypeString', geometry_type=None, has_z=False, has_m=False, default_value=None, nullable=True, visible=True, editable=True, required=False, is_system_maintained=False, role='esriGraphPropertyRegular')\n",
" ], \n",
" field_indexes=[\n",
" FieldIndex(name='esri__oid_idx', is_ascending=True, is_unique=True, fields=['objectid']), \n",
" FieldIndex(name='esri__globalid_idx', is_ascending=True, is_unique=True, fields=['globalid'])\n",
" ]\n",
")\n",
"```"
]
},
Expand Down Expand Up @@ -332,7 +262,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.12.3"
},
"vscode": {
"interpreter": {
Expand Down
Loading