defaultQuery property
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
inQueryType.search
type of components. - To modify the
aggregations
inQueryType.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'],
},
},
}
)
Implementation
final Map Function(SearchController searchController)? defaultQuery;