searchField method
- @Assert('weight != null && (weight < 1 || weight > 10)', 'The value of the weight parameter must be an integer between 1 and 10.')
Takes a field with an optional weight
, creates and returns a new ElasticSuggestionsQuery
It will restrict a query to search only specific fields.
Weight is given between 10 (most relevant) to 1 (least relevant).
Restricting fields will result in faster queries, especially for schemas with many text fields Only available within text fields.
See https://www.elastic.co/guide/en/app-search/current/search-fields-weights.html
Implementation
@Assert('weight != null && (weight < 1 || weight > 10)',
'The value of the weight parameter must be an integer between 1 and 10.')
ElasticSuggestionsQuery searchField(
String field, {
int? weight,
}) {
return copyWith(
searchFields: [
...?searchFields,
_ElasticSearchField(
name: field,
weight: weight,
),
],
);
}