Skip to content
import GraphSearch from "@arcgis/core/rest/knowledgeGraph/GraphSearch.js";
Inheritance:
GraphSearchAccessor
Subclasses:
GraphSearchStreaming
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.

See also
Examples
//searches for 'solar' in the properties of all entities in the knowledge graph
const knowledgeGraphModule = await $arcgis.import("@arcgis/core/rest/knowledgeGraphService.js");
KnowledgeGraphModule
.executeSearch(kg, {
searchQuery: "solar",
typeCategoryFilter: "entity",
})
.then((queryResult) => {
// do something with the search results
console.log("Graph Search Result", queryResult);
});
//sample return from above search
[{
"declaredClass": "esri.rest.knowledgeGraph.Entity",
"properties": {
"shape": {
"declaredClass": "esri.geometry.Point",
"cache": {},
"hasM": false,
"hasZ": false,
"latitude": 53.589000000000009,
"longitude": -0.9633,
"type": "point",
"extent": null,
"spatialReference": {
"wkid": 4326
},
"x": -0.9633,
"y": 53.589000000000009
},
"Name": "Suncommon",
"Employee_Count": 400,
"energyType": "solar"
},
"typeName": "Company",
"id": "156786"
}]

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.

searchQuery

Property
Type
string

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

Required

executeSearch() will fail if not provided.

Default value
""

typeCategoryFilter

Property
Type
ValidTypeCategoryFilter

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"

Type definitions

ValidTypeCategoryFilter

Type definition
Type
"entity" | "relationship" | "both" | "provenance"