Pipeline
The Pipeline
class is required to configure which pipeline to use for search queries and must be passed to the SearchProvider
.
Usage
Replace the demo information with your account ID and collection ID and pipeline (e.g. 'query'
) from the console.
Constructor
The constructor accepts the following arguments:
Argument | Type | Default | Description |
---|---|---|---|
0 | { account: string; collection: string; endpoint?: string;} | Account, collection and endpoint configuration. | |
1 | string | { name: string; version?: string } | The pipeline configuration. | |
2 | ClickTracking | NoTracking | new NoTracking() | Default tracking to use in searches. |
3 | ClickTracking | NoTracking | [GoogleAnalytics] | Default tracking to use in searches. |
Properties
For more advanced implementations, you may want to call methods on the Pipeline
instance.
Name | Description |
---|---|
search(variables) | Perform a search. |
listen(event: string, callback: () => void) | Register a listener for a specific event. |
clearResponse(variables) | Clears the error, response, and response variables from this object. |
getResponse() | Returns the current response. |
getAnalytics() | Returns the analytics adaptor connected to this pipeline. |
getClient() | Returns the underlying JavaScript SDK client. |
Search example
To perform a search you need a dictionary of parameter key-value pairs.
This will return a Response
object.
Listen example
Register listeners to be notified when search responses come back from the server, or are cleared by UI events. Every listener is passed a Response
which wraps the server response with convenience methods: