GraphSearchStreaming

AMD: require(["esri/rest/knowledgeGraph/GraphSearchStreaming"], (GraphSearchStreaming) => { /* code goes here */ });
ESM: import GraphSearchStreaming from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
Class: esri/rest/knowledgeGraph/GraphSearchStreaming
Inheritance: GraphSearchStreaming GraphSearch Accessor
Since: ArcGIS Maps SDK 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"],
    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

GraphSearchStreaming

Constructor
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

The name of the class.

Accessor

Specifies list of IDs to search.

GraphSearchStreaming

Specifies list of names of entity types or relationship types to search.

GraphSearchStreaming

The maximum number of results returned from the search.

GraphSearchStreaming

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.

GraphSearchStreaming

The text to search for in the knowledge graph.

GraphSearch

The index of the first result to return.

GraphSearchStreaming

Specifies whether to search entities, relationships, or both.

GraphSearch

Property Details

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

idsFilter

Property
idsFilter String[]

Specifies list of IDs to search.

namedTypesFilter

Property
namedTypesFilter String[]

Specifies list of names of entity types or relationship types to search.

num

Property
num Number

The maximum number of results returned from the search.

returnSearchContext

Property
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

Inherited
Property
searchQuery String
Inherited from GraphSearch

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

Required

start

Property
start Number

The index of the first result to return.

typeCategoryFilter

Inherited
Property
typeCategoryFilter String
Inherited from GraphSearch

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.

Accessor

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor

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 }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
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

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

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

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

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.