Skip to content
import GraphSearchStreaming from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
Inheritance:
GraphSearchStreamingGraphSearchAccessor
Since
ArcGIS Maps SDK for JavaScript 4.25

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 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.

See also
Examples
// 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

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

idsFilter

Property
Type
string[] | null | undefined

Specifies list of IDs to search.

namedTypesFilter

Property
Type
string[] | null | undefined

Specifies list of names of entity types or relationship types to search. Note that if the typeCategoryFilter property is set to provenance, the search is restricted to the provenance meta entity type; entering any values other than the provenance meta entity type name will result in an error.

num

Property
Type
number | null | undefined

The maximum number of results returned from the search.

returnSearchContext

Property
Type
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

searchQuery

inherited Property
Type
string
Inherited from: GraphSearch

The text to search for in the knowledge graph. Accepts Lucene search syntax.

Required

executeSearch() will fail if not provided.

Default value
""

start

Property
Type
number | null | undefined

The index of the first result to return.

typeCategoryFilter

inherited Property
Type
ValidTypeCategoryFilter
Inherited from: GraphSearch

Specifies whether to search entities, relationships, both entities and relationships, or the provenance meta entity type. Valid values are entity, relationship, both or provenance.

Note

Check the service definition for the knowledgeGraphService (see ArcGIS REST APIs - Hosted Knowledge Graph Service) for valid values of typeCategoryFilter. Not all services support both or provenance.

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.

Default value
"both"