import GraphSearch from "@arcgis/core/rest/knowledgeGraph/GraphSearch.js";const GraphSearch = await $arcgis.import("@arcgis/core/rest/knowledgeGraph/GraphSearch.js");- Inheritance:
- GraphSearch→
Accessor
- 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.
Examples
//searches for 'solar' in the properties of all entities in the knowledge graphconst 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
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
| | ||
| |
searchQuery
- 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
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"