defaultQuery property

Map Function(SearchWidget searchWidget) defaultQuery
read / write

is a callback function that takes the SearchWidget 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 or results 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 (SearchWidget searchWidget) => ({
  		'query': {
  			'terms': {
  				'country': ['India'],
  			},
  		},
  	}
  )

Implementation

Map Function(SearchWidget searchWidget) defaultQuery;