The search operation is performed on a knowledge graph service's
graph resource.
This operation allows you to search the properties of both entities and
relationships in the graph.
Any field with the text
data type or the Globally Unique Identifier (GUID) data type with the
searchable properties set to true
is included in the search.
A search index is built and maintained automatically on the values for all searchable fields.
Streaming search returns the result faster than search and in small chunks that can be rendered immediately. Streaming search also provides additional parameters to constrain the search.
// example GraphSearchStreaming used in a executeSearchStreaming
KnowledgeGraphModule.executeSearchStreaming(
knowledgeGraph,
{ // autocasts to new GraphSearchStreaming
searchQuery: "solar",
typeCategoryFilter: "both",
returnSearchContext: false,
start: 1, // index of first record to return
num: 200, // return 200 records.
namedTypesFilter: ["Company", "Supplier", "Part"],
idsFilter: ["{G4E8G2S8D-2GS5-98S4-3S5D-S1DE7G45DS48}",
"{FNWI1G5W-1A5W-3A5W-8412-A1W5F4W8F7AS}",
"{9D2D6AFD-41F1-49A4-8412-CACCC9906E88}"]
}
).then((streamingSearchResult)=>{
// the result of a streaming search is a readableStream which requires decoding.
readStream(streamingSearchResult)
})
// a function to read the readable stream returned from the above query
const readStream = async (streamingQueryResult) => {
let time = Date.now();
let reader = streamingQueryResult.resultRowsStream.getReader();
try {
while (true) {
const { done, value } = await reader.read();
if (done) {
console.log(`Completed database requests: ${(Date.now() - time) / 1000} seconds`, value);
break;
}
console.log(`Chunk returned in: ${(Date.now() - time) / 1000} seconds`, value)
}
} catch (err) {
if (err.name === "AbortError") {
console.log("Request aborted as expected");
} else {
throw err;
}
}
};
// sample result of read streaming search result chunk printed to the console
"Streaming chunk returned in: 0.082 seconds"
[
[{
"declaredClass": "esri.rest.knowledgeGraph.Entity",
"properties": {
"Name": "Suncommon",
"Employee_Count": 400,
"energyType": "solar"
},
"typeName": "Company",
"id": "{G4E8G2S8D-2GS5-98S4-3S5D-S1DE7G45DS48}"
}],
[{
"declaredClass": "esri.rest.knowledgeGraph.Entity",
"properties": {
"Name": "Quality Solar Supply",
"Supplier_code": "158B",
"City": "New Orleans",
},
"typeName": "Supplier",
"id": "{FNWI1G5W-1A5W-3A5W-8412-A1W5F4W8F7AS}"
}],
[{
"declaredClass": "esri.rest.knowledgeGraph.Entity",
"properties": {
"Name": "Solar panel",
"panel_type": "Polycrystalline",
"price_per_unit": 400
},
"typeName": "Part",
"id": "{9D2D6AFD-41F1-49A4-8412-CACCC9906E88}"
}]
]
Constructors
-
new GraphSearchStreaming(properties)
-
Parameterproperties Objectoptional
See the properties for a list of all the properties
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
String | The name of the class. more details | Accessor | |
String[] | Specifies list of IDs to search. more details | GraphSearchStreaming | |
String[] | Specifies list of names of entity types or relationship types to search. more details | GraphSearchStreaming | |
Number | The maximum number of results returned from the search. more details | GraphSearchStreaming | |
Boolean | If | GraphSearchStreaming | |
String | The text to search for in the knowledge graph. more details | GraphSearch | |
Number | The index of the first result to return. more details | GraphSearchStreaming | |
String | Specifies whether to search entities, relationships, or both. more details | GraphSearch |
Property Details
-
The name of the class. The declared class name is formatted as
esri.folder.className
.
-
Specifies list of IDs to search.
-
Specifies list of names of entity types or relationship types to search.
-
num Number
-
The maximum number of results returned from the search.
-
returnSearchContext Boolean
-
If
true
, returns the IDs of objects that match the search, the names of the properties that matched the search term, scores and highlights of the result set.- Default Value:false
-
The text to search for in the knowledge graph. Accepts Lucene search syntax.
Required
- knowledgeGraphService.executeSearch() will fail if not provided.
-
start Number
-
The index of the first result to return.
-
Specifies whether to search entities, relationships, or both. Valid values are
entity
,relationship
, orboth
.Note
- Check the service definition for the knowledgeGraphService (see ArcGIS REST APIs - Hosted Knowledge Graph Service) for valid values of
typeCategoryFilter
. Not all services supportboth
.
Required
- This property is required for the search to execute successfully. If the service does not support
both
one of the other options must be specified.
Possible Values:"entity"|"relationship"|"both"
- Default Value:"both"
- Check the service definition for the knowledgeGraphService (see ArcGIS REST APIs - Hosted Knowledge Graph Service) for valid values of
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. more details | Accessor | ||
Boolean | Returns true if a named group of handles exist. more details | Accessor | |
Removes a group of handles owned by the object. more details | Accessor |
Method Details
-
addHandles(handleOrHandles, groupKey)inherited
-
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
removeHandles(groupKey)inherited
-
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");