Knowledge Graph Data Model Editing

Note: Sign in to access the data in this sample. username: editor01 password: S7#i2LWmYH75

Getting Started

Knowledge graphs allow you to model real-world systems that contain both spatial and nonspatial entities (such as people, places and things) and the relationships that connect them, allowing you to leverage both spatial and nonspatial tools in your analysis. A knowledge graph allows you work with a graph network. Both entities and relationships are objects in the graph data structure and can have associated properties. Entity types can be defined with or without spatial information.

The sample dataset contains observations of bumble bees made at locations around the United States. Each observation was made and verified by users and is of a specific species of bumble bee.

sample-data-model

1. Sign in

The data in this example is secured, as most knowledge graph data will be since the ArcGIS Knowledge Graph Server license is required. Therefore, the first step is to sign in to load the data.

2. Fetch the graph

In order to update the data model for a knowledge graph, you first have to fetch the graph which retrieves the knowledge graph service definition and the current data model.

Use dark colors for code blocksCopy
1
 let kg = await KnowledgeGraphService.fetchKnowledgeGraph(url)

3. Add new named types

Start by adding a new entity type to the graph. First define the entity type to add.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
      //define the new entity type
      const newEntityType = {
        type: "entity",
        name: "MyNewEntityType" + Math.floor(Math.random() * 100) + 1,
        alias: "NewEntityType",
        properties: [
          {
            name: "name",
            alias: "full name",
            fieldType: "esriFieldTypeString",
            defaultValue: "new entity",
            role: "esriGraphPropertyRegular",
          },
          {
            name: "shape",
            alias: "location",
            fieldType: "esriFieldTypeGeometry",
            geometryType: "esriGeometryPoint",
            role: "esriGraphPropertyRegular",
            required: false,
            editable: true,
          },
        ],
      };

Then use knowledgeGraphService.executeAddNamedTypes() to add the new entity type to the knowledge graph. The knowledge graph data model will be updated with a new entity type that contains a name property and a shape property.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
      //Add the new entity type to the knowledge graph data model
      KnowledgeGraphService
        .executeAddNamedTypes(kg, {
          newEntityTypes: [newEntityType],
        })
        .then((response) => {
          console.log("Response from add named types: ", response);
          //set the working knowledge graph to be the newly updated graph
          kg = response.updatedKnowledgeGraph;
          updateUI(newEntityType.name);

        })
        .catch((e) => {
          //catch errors and provide user feedback
        });

Next add a new relationship type by to the graph. Relationships include additional information about the origin entity types and destination entity types for the relationship type.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
      //define the new relationship type
      const newRelationshipType = {
        type: "relationship",
        name: "MyNewRelationshipType" + Math.floor(Math.random() * 100) + 1,

        properties: [
          {
            name: "nameProp",
            fieldType: "esriFieldTypeString",
            role: "esriGraphPropertyRegular",
          },
        ],
        endPoints: [
          {
            originEntityType: "Observation",
            destinationEntityType: "User",
          },
        ],
      };

Add the new relationship type to the knowledge graph data model using the same executeAddNamedTypes(). You can add entity types and relationship types to the data model in the same executeAddNamedTypes() call as separate lists. The knowledge graph data model will be updated with a new relationship type that contains a name property. The origin and destination entity types for this relationship are set as Observation and User.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
      //add it to the knowledge graph data model
      KnowledgeGraphService
        .executeAddNamedTypes(kg, {
          newRelationshipTypes: [newRelationshipType],
        })
        .then((response) => {
          //set the working knowledge graph to be the newly updated graph
          //with the new type and update the UI.
          kg = response.updatedKnowledgeGraph;
          updateUI(newRelationshipType.name);
        })
        .catch((e) => {
          //catch errors and provide user feedback
        });

4. Add a graph property to a named type

Graph properties can be added to entity types and relationship types after they are created. Graph properties are the properties that all instances of an entity type or relationship type will have. For example, the User entity type has a graph property username so all User entities will have a username property. To add a graph property, click the plus under the type and provide a name for the graph property. All properties added to an existing named type must have the nullable property set to true so that existing records of that type can be updated with the new property.

See GraphProperty for more information on the properties you can set for a graph property.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
    /**
     * Add a GraphProperty to an existing entity type or relationship type
     */
    const addPropertyToType = (namedType, name) => {
      KnowledgeGraphService
        .executeAddGraphProperties(kg, namedType, [
          {//autocasts as a new GraphProperty
            name: name,
            fieldType: "esriFieldTypeString",
            role: "esriGraphPropertyRegular",
            nullable: true, //when you are adding a property to an existing type you must set nullable to true
          }
        ])
        .then((response) => {
          kg = response.updatedKnowledgeGraph;
          updateUI(namedType, name);

        })
        .catch((e) => {
          //catch errors and provide user feedback
        });
    }

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