KeysToSubscribe enum
Constructors
- KeysToSubscribe()
-
const
Values
- Results → const KeysToSubscribe
-
It is an object that represents the elasticsearch query response.
- AggregationData → const KeysToSubscribe
-
An object that contains the aggregations data for QueryType.term queries.
- RequestStatus → const KeysToSubscribe
-
Represents the current status of the elasticsearch request, whether PENDING, INACTIVE, ERROR
- Error → const KeysToSubscribe
-
Represents the error response returned by elasticsearch.
- Value → const KeysToSubscribe
-
Represents the value for a particular QueryType.
Depending on the query type, the value format would differ. You can refer to the different value formats over here.
- Query → const KeysToSubscribe
-
returns the last query executed by the widget
- DataField → const KeysToSubscribe
-
The index field(s) to be connected to the component’s UI view.
It accepts an
List<String>
in addition to<String>
, which is useful for searching across multiple fields with or without field weights.Field weights allow weighted search for the index fields. A higher number implies a higher relevance weight for the corresponding field in the search results. You can define the
dataField
property as aList<Map>
of to set the field weights. The object must have thefield
andweight
keys. For example,[ { 'field': 'original_title', 'weight': 1 }, { 'field': 'original_title.search', 'weight': 3 }, ]
- Size → const KeysToSubscribe
-
Number of suggestions and results to fetch per request.
- From → const KeysToSubscribe
-
To define from which page to start the results, it is important to implement pagination.
- Fuzziness → const KeysToSubscribe
-
Useful for showing the correct results for an incorrect search parameter by taking the fuzziness into account.
For example, with a substitution of one character,
fox
can becomebox
. Read more about it in the elastic search https://www.elastic.co/guide/en/elasticsearch/guide/current/fuzziness.html. - IncludeFields → const KeysToSubscribe
-
It allows to define fields to be included in search results.
- ExcludeFields → const KeysToSubscribe
-
It allows to define fields to be excluded in search results.
- SortBy → const KeysToSubscribe
-
Sorts the results by either SortType.asc, SortType.desc or SortType.count order.
Please note that the SortType.count is only applicable for QueryType.term type of search widgets.
- React → const KeysToSubscribe
-
It is useful for components whose data view should reactively update when on or more dependent components change their states.
For example, a widget to display the results can depend on the search widget to filter the results.
- key
string
one ofand
,or
,not
defines the combining clause.- and clause implies that the results will be filtered by matches from all of the associated widget states.
- or clause implies that the results will be filtered by matches from at least one of the associated widget states.
- not clause implies that the results will be filtered by an inverse match of the associated widget states.
- value
string or Array or Object
string
is used for specifying a single widget by itsid
.Array
is used for specifying multiple components by theirid
.Object
is used for nesting other key clauses. An example of areact
clause where all three clauses are used and values areObject
,Array
andstring
.
{ 'and': { 'or': ['CityComp', 'TopicComp'], 'not': 'BlacklistComp', }, }
Here, we are specifying that the results should update whenever one of the blacklist items is not present and simultaneously any one of the city or topics matches.
- key
- DefaultQuery → const KeysToSubscribe
-
It is a callback function that takes the SearchController instance as parameter and returns the data query to be applied to the source component, as defined in Elasticsearch Query DSL, which doesn't get leaked to other components.
In simple words,
defaultQuery
is used with data-driven components to impact their own data. It is meant to modify the default query which is used by a component to render the UI.Some of the valid use-cases are:
- To modify the query to render the
suggestions
orresults
in QueryType.search type of components. - To modify the
aggregations
in QueryType.term type of components.
For example, in a QueryType.term type of component showing a list of cities, you may only want to render cities belonging to
India
.Map (SearchController searchController) => ({ 'query': { 'terms': { 'country': ['India'], }, }, } )
- To modify the query to render the
- CustomQuery → const KeysToSubscribe
-
It takes SearchController instance as parameter and returns the query to be applied to the dependent widgets by
react
prop, as defined in Elasticsearch Query DSL.For example, the following example has two components search-widget(to render the suggestions) and result-widget(to render the results). The result-widget depends on the search-widget to update the results based on the selected suggestion. The search-widget has the
customQuery
prop defined that will not affect the query for suggestions(that is howcustomQuery
is different fromdefaultQuery
) but it'll affect the query for result-widget because of thereact
dependency on search-widget.SearchWidgetConnector( id: "search-widget", dataField: ["original_title", "original_title.search"], customQuery: (SearchController searchController) => ({ 'timeout': '1s', 'query': { 'match_phrase_prefix': { 'fieldName': { 'query': 'hello world', 'max_expansions': 10, }, }, }, }) ) SearchWidgetConnector( id: "result-widget", dataField: "original_title", react: { 'and': ['search-component'] } )
- RequestPending → const KeysToSubscribe
-
Useful for getting the status of the API, whether it has been executed or not
- RecentSearches → const KeysToSubscribe
-
A list of recent searches as suggestions.
- After → const KeysToSubscribe
-
This property can be used to implement the pagination for
aggregations
.We use the composite aggregations of
Elasticsearch
to execute the aggregations' query, the response of composite aggregations includes a key namedafter_key
which can be used to fetch the next set of aggregations for the same query. You can read more about the pagination for composite aggregations at here.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
KeysToSubscribe> - A constant List of the values in this enum, in order of their declaration.