buildShouldQuery method
- String? query
Builds the optional "should" query clauses for keyword-based search.
This method constructs the should clause of the query, allowing
products to be filtered by keywords such as name, art, text, brand,
or barcode.
-
Parameters:
- query: The optional keyword query to search for in product fields.
-
Returns: A list of query clauses to be used in the
shouldclause, ornullif no query is provided.
Implementation
List<QueryClause>? buildShouldQuery(String? query) {
return (query != null && query.isNotEmpty)
? <QueryClause>[
QueryMatch('name', query),
QueryMatch('art', query),
QueryMatch('text', query),
QueryMatch('brand_name', query),
QueryMatch('barcode', query),
]
: null;
}