@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
92 lines (89 loc) • 4.44 kB
TypeScript
import type Accessor from "../../core/Accessor.js";
export interface GraphSearchProperties extends Partial<Pick<GraphSearch, "searchQuery" | "typeCategoryFilter">> {}
/**
* The search operation is performed on a [knowledge graph service's](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/)
* [graph](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/KnowledgeGraph/) resource.
* This operation allows you to search the properties of both [entities](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Entity/) and
* [relationships](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/) in the graph.
* Any field with the Text data type or the [Globally Unique Identifier (GUID)](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/arcgis-field-data-types.htm#GUID-97064FAE-B42E-4DC3-A5C9-9A6F12D053A8) data type with the
* A search index is built and maintained automatically on the values for all searchable fields.
*
* @since 4.25
* @see [Sample - Search a knowledge graph](https://developers.arcgis.com/javascript/latest/sample-code/knowledgegraph-search/)
* @see [executeSearch()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeSearch)
* @see [executeSearchStreaming()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeSearchStreaming)
* @example
* //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);
* });
* @example
* //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"
* }]
*/
export default class GraphSearch extends Accessor {
constructor(properties?: GraphSearchProperties);
/**
* The text to search for in the knowledge graph. Accepts [Lucene search syntax](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html).
*
* > [!WARNING]
* >
* > **Required**
* >
* > [executeSearch()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeSearch) will fail if not provided.
*
* @default ""
*/
accessor searchQuery: string;
/**
* Specifies whether to search [entities](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/), [relationships](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/), both entities and relationships, or the provenance meta entity type.
* Valid values are `entity`, `relationship`, `both` or `provenance`.
*
* > [!WARNING]
* >
* > **Note**
* >
* > Check the service definition for the [knowledgeGraphService](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/) (see [ArcGIS REST APIs - Hosted Knowledge Graph Service](https://developers.arcgis.com/rest/services-reference/enterprise/kgs-hosted-server.htm)) for valid values of `typeCategoryFilter`. Not all services support `both` or `provenance`.
*
* > [!WARNING]
* >
* > **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 "both"
*/
accessor typeCategoryFilter: ValidTypeCategoryFilter;
}
export type ValidTypeCategoryFilter = "entity" | "relationship" | "both" | "provenance";