SearchBox<S, ViewModel> class

SearchBox offers a performance focused searchbox UI widget to query and display results from your Elasticsearch cluster.

It extends the SearchDelegate class which means that to display the SearchBox UI you have to invoke the showSearch method with SearchBox as delegate.

Inheritance

Constructors

Properties

after Map?
This property can be used to implement the pagination for aggregations.
final
aggregationField String?
It enables you to get DISTINCT results (useful when you are dealing with sessions, events, and logs type data).
final
aggregations List<String>?
It helps you to utilize the built-in aggregations for QueryType.range type of widgets directly, valid values are:
final
aggregationSize int?
To set the number of buckets to be returned by aggregations.
final
appbaseConfig → AppbaseSettings?
It allows you to customize the analytics experience when appbase.io is used as a backend.
final
automaticallyImplyLeading bool?
Controls whether we should try to imply the leading widget if null.
getter/setter pairinherited
beforeValueChange → (Future Function(dynamic value)?)
It is a callback function which accepts component's future value as a parameter and returns a Future.
final
buildSuggestionItem → (Widget Function(Suggestion suggestion, Function handleTap)?)
It can be used to render the custom UI for suggestion list item.
final
categoryField String?
Index field mapped to the category value.
final
categoryValue String?
This is the selected category value. It is used for informing the search result.
final
clearOnQueryChange bool
When set to true, the dependent controller's (which is set via react prop) value would get cleared whenever the query changes.
final
compoundClause ↔ CompoundClauseType?
Configure whether the DSL query is generated with the compound clause of CompoundClauseType.must or CompoundClauseType.filter. If nothing is passed the default is to use CompoundClauseType.must. Setting the compound clause to filter allows search engine to cache and allows for higher throughput in cases where scoring isn’t relevant (e.g. term, geo or range type of queries that act as filters on the data)
getter/setter pair
credentials String?
Basic Auth credentials if required for authentication purposes.
final
customActions List<Widget>?
customActions allows to define the additional actions at the right of search bar.
getter/setter pair
customHighlight Map?
It can be used to set the custom highlight settings.
final
customQuery → (Map Function(dynamic searchController)?)
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.
final
dataField → dynamic
The index field(s) to be connected to the component’s UI view.
final
defaultQuery → (Map Function(dynamic searchController)?)
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.
final
distinctField String?
This prop returns only the distinct value documents for the specified field. It is equivalent to the DISTINCT clause in SQL. It internally uses the collapse feature of Elasticsearch. You can read more about it over here - https://www.elastic.co/guide/en/elasticsearch/reference/current/collapse-search-results.html
final
distinctFieldConfig Map?
This prop allows specifying additional options to the distinctField prop. Using the allowed DSL, one can specify how to return K distinct values (default value of K=1), sort them by a specific order, or return a second level of distinct values. distinctFieldConfig object corresponds to the inner_hits key's DSL. You can read more about it over here - https://www.elastic.co/guide/en/elasticsearch/reference/current/collapse-search-results.html
final
enablePopularSuggestions bool?
It can be useful to curate search suggestions based on actual search queries that your users are making.
final
enableRecentSearches bool
If set to true then users will see the top recent searches as the default suggestions.
final
enableSynonyms bool?
This property can be used to control (enable/disable) the synonyms behavior for a particular query.
final
excludeFields List<String>?
final
from int?
To define from which page to start the results, it is important to implement pagination.
final
fuzziness → dynamic
Useful for showing the correct results for an incorrect search parameter by taking the fuzziness into account.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>?
Set custom headers to be sent with each server request as key/value pairs.
final
highlight bool?
To define whether highlighting should be enabled in the returned results.
final
highlightField → dynamic
If highlighting is enabled, this property allows specifying the fields which should be returned with the matching highlights.
final
id String
A unique identifier of the component, can be referenced in other widgets' react prop to reactively update data.
final
includeFields List<String>?
final
includeNullValues bool?
If you have sparse data or documents or items not having the value in the specified field or mapping, then this prop enables you to show that data.
final
index String?
Refers to an index of the Elasticsearch cluster.
final
interval int?
To set the histogram bar interval for QueryType.range type of widgets, applicable when aggregations value is set to ["histogram"].
final
keyboardType TextInputType?
The type of action button to use for the keyboard.
finalinherited
leadingWidth double?
Defines the width of AppBar.leading widget.
getter/setter pairinherited
maxPopularSuggestions int?
It can be used to configure the size of popular suggestions.
final
micOptions MicOptions?
To customize the mic settings if voice search is enabled
final
missingLabel String?
It allows you to specify a custom label to show when showMissing is set to true.
final
nestedField String?
Sets the nested field path that allows an array of objects to be indexed in a way that can be queried independently of each other.
final
onAggregationData → (void Function(Aggregations next, {Aggregations prev})?)
It can be used to listen for the aggregationData property changes.
final
onError → (void Function(dynamic error)?)
It gets triggered in case of an error occurs while fetching results.
final
onQueryChange → (void Function(List<Map>? next, {List<Map>? prev})?)
It is a callback function which accepts widget's nextQuery and prevQuery as parameters.
final
onRequestStatusChange → (void Function(String next, {String prev})?)
It can be used to listen for the request status changes.
final
onResults → (void Function(Results next, {Results prev})?)
It can be used to listen for the results changes.
final
onValueChange → (void Function(dynamic next, {dynamic prev})?)
It is called every-time the widget's value changes.
final
pagination bool?
This property allows you to implement the pagination for QueryType.term type of queries.
final
preserveResults bool?
It set to true then it preserves the previously loaded results data that can be used to persist pagination or implement infinite loading.
final
query String
The current query string shown in the AppBar.
getter/setter pairinherited
queryFormat String?
Sets the query format, can be or or and.
final
queryString bool?
If set to true than it allows you to create a complex search that includes wildcard characters, searches across multiple fields, and more.
final
react Map<String, dynamic>?
It is useful for components whose data view should reactively update when on or more dependent components change their states.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchFieldDecorationTheme InputDecorationTheme?
The InputDecorationTheme used to configure the search field's visuals.
finalinherited
searchFieldLabel String?
The hint text that is shown in the search field when it is empty.
finalinherited
searchFieldStyle TextStyle?
The style of the searchFieldLabel.
finalinherited
searchOperators bool?
If set to true, then you can use special characters in the search query to enable the advanced search.
final
selectAllLabel String?
This property allows you to add a new property in the list with a particular value in such a way that when selected i.e value is similar/contains to that label(selectAllLabel) then QueryType.term query will make sure that the field exists in the results.
final
showAutoFill bool
This property allows you to enable the auto-fill behavior for suggestions.
final
showDistinctSuggestions bool
To display one suggestion per document.
final
showMissing bool?
When set to true then it also retrieves the aggregations for missing fields.
final
size int?
Number of suggestions and results to fetch per request.
final
sortBy → SortType?
Sorts the results by either SortType.asc, SortType.desc or SortType.count order.
final
speechToTextInstance → dynamic
This property allows to enable the voice search.
final
textInputAction TextInputAction
The text input action configuring the soft keyboard to a particular action button.
finalinherited
transformRequest → TransformRequest?
Enables transformation of network request before execution.
final
transformResponse → TransformResponse?
Enables transformation of search network response before rendering them.
final
transitionAnimation Animation<double>
Animation triggered when the search pages fades in or out.
no setterinherited
url String?
URL for the Elasticsearch cluster.
final

Methods

appBarTheme(BuildContext context) ThemeData
The theme used to configure the search page.
inherited
buildActions(BuildContext context) List<Widget>
Widgets to display after the search query in the AppBar.
override
buildBottom(BuildContext context) PreferredSizeWidget?
Widget to display across the bottom of the AppBar.
inherited
buildFlexibleSpace(BuildContext context) Widget?
Widget to display a flexible space in the AppBar.
inherited
buildLeading(BuildContext context) Widget
A widget to display before the current query in the AppBar.
override
buildResults(BuildContext context) Widget
The results shown after the user submits a search from the search page.
override
buildSuggestions(BuildContext context) Widget
Suggestions shown in the body of the search page while the user types a query into the search field.
override
close(BuildContext context, String? result) → void
Closes the search page and returns to the underlying route.
inherited
dispose() → void
Releases the resources.
inherited
getSuggestionList(BuildContext context, dynamic searchController, List<Suggestion> list) ListView
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
showResults(BuildContext context) → void
Transition from the suggestions returned by buildSuggestions to the query results returned by buildResults.
inherited
showSuggestions(BuildContext context) → void
Transition from showing the results returned by buildResults to showing the suggestions returned by buildSuggestions.
inherited
toString() String
A string representation of this object.
inherited

Operators

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