GraphSearchStreaming

AMD: require(["esri/rest/knowledgeGraph/GraphSearchStreaming"], (GraphSearchStreaming) => { /* code goes here */ });
ESM: import GraphSearchStreaming from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming";
Class: esri/rest/knowledgeGraph/GraphSearchStreaming
Inheritance: GraphSearchStreaming GraphSearch Accessor
Since: ArcGIS API for JavaScript 4.25
beta

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.

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"],
    globalIdsFilter: ["{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)
Parameter
properties Object
optional

See the properties for a list of all the properties

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
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 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.

more details
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

declaredClass Stringreadonly inherited

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

globalIdsFilter String[]

Specifies list of IDs to search.

namedTypesFilter String[]

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
searchQuery String inherited

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

Required

start Number

The index of the first result to return.

typeCategoryFilter String inherited

Specifies whether to search entities, relationships, or both. Valid values are entity, relationship, or both.

Note

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"

Method Overview

Show inherited methods Hide inherited methods
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 }
);

// Handle gets removed when the object is destroyed.
this.addHandles(handle);
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

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

hasHandles(groupKey){Boolean}inherited

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

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

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.