SearchBase class

The SearchBase class holds the state for all the active SearchWidgets and can be used to provide the global configuration to the registered SearchWidgets.

It serves the following tasks:

  • To register a SearchWidget by unique id
  • To unregister a SearchWidget by id
  • To retrieve the instance of the SearchWidget class by id
  • To provide an ability to watch registered widget reactively with the help of the react property.

Note:

  1. The id property is a unique identifier to each search widget.
  2. The SearchBase class is useful when you're using multiple search widgets that depend on each other. For example, a filter widget (to display the category options) depends on the search query (search widget). If you're only using a single widget then SearchWidget class should work well.

Constructors

SearchBase(String index, String url, String credentials, {AppbaseSettings appbaseConfig, TransformRequest transformRequest, TransformResponse transformResponse, Map<String, String> headers})

Properties

appbaseConfig AppbaseSettings
It allows you to customize the analytics experience when appbase.io is used as a backend.
read / write, inherited
credentials String
Basic Auth credentials if required for authentication purposes. [...]
read / write, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
headers Map<String, String>
Set custom headers to be sent with each server request as key/value pairs.
read / write, inherited
index String
Refers to an index of the Elasticsearch cluster. [...]
read / write, inherited
queryId String
To get the query ID
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
transformRequest TransformRequest
Enables transformation of network request before execution. This function will give you the request object as the param and expect an updated request in return, for execution. [...]
read / write, inherited
transformResponse TransformResponse
Enables transformation of search network response before rendering them. [...]
read / write, inherited
url String
URL for the Elasticsearch cluster.
read / write, inherited

Methods

click(Map<String, int> objects, {bool isSuggestionClick: false, String queryId}) Future
use this methods to record a search click event
inherited
conversion(List<String> objects, {String queryId}) Future
use this methods to record a search conversion
inherited
getActiveWidgets() Map<String, SearchWidget>
This method returns all the active widgets registered on the SearchBase instance. The widgets state can be used for various purposes, for example, to display the selected filters in the UI.
getSearchWidget(String widgetId) SearchWidget
This method can be used to retrieve the instance of the SearchWidget class for a particular widget by id.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
register(String widgetId, dynamic searchWidget) SearchWidget
This method can be used to register a search widget with a unique id. [...]
setHeaders(Map<String, String> headers) → void
To to set the custom headers
inherited
setQueryID(String queryID) → void
To set the query ID
inherited
toString() String
Returns a string representation of this object.
inherited
unregister(String widgetId) → void
This method is useful to unregister a SearchWidget by id. [...]

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited