ElasticQuery constructor

  1. @JsonSerializable(explicitToJson: true, includeIfNull: false)
  2. @Assert('engine != null', 'An engine is required to build a query.')
  3. @Assert('precisionTuning == null || (precisionTuning != null && precisionTuning >= 1 && precisionTuning <= 11)', 'The value of the precision parameter must be an integer between 1 and 11, inclusive.')
const ElasticQuery({
  1. @JsonKey(includeToJson: false) ElasticEngine? engine,
  2. required String query,
  3. @protected @JsonKey(name: "precision") int? precisionTuning,
  4. @JsonKey(name: "page") _ElasticSearchPage? searchPage,
  5. @_ElasticSearchFiltersConverter() List<_ElasticSearchFilter>? filters,
  6. @_ElasticSearchFieldsConverter() @JsonKey(name: "search_fields") List<_ElasticSearchField>? searchFields,
  7. @_ElasticResultFieldsConverter() @JsonKey(name: "result_fields") List<_ElasticResultField>? resultFields,
  8. @protected Map<String, _ElasticQueryFacet>? facets,
  9. @JsonKey(includeToJson: false) List<String>? disjunctiveFacets,
  10. _ElasticAnalytics? analytics,
  11. @protected @JsonKey(name: "group") _ElasticGroup? groupBy,
  12. @_ElasticSortConverter() @JsonKey(name: "sort") List<_ElasticSort>? sortBy,
})

Implementation

@JsonSerializable(
  explicitToJson: true,
  includeIfNull: false,
)
@Assert('engine != null', 'An engine is required to build a query.')
@Assert(
    'precisionTuning == null || (precisionTuning != null && precisionTuning >= 1 && precisionTuning <= 11)',
    'The value of the precision parameter must be an integer between 1 and 11, inclusive.')
const factory ElasticQuery({
  /// An object representing an Elastic engine
  @JsonKey(includeToJson: false)
      ElasticEngine? engine,

  /// String or number to match.
  required String query,

  /// Use the precision parameter of the search API to tune precision
  /// and recall for a query. Learn more in Precision tuning (beta).
  /// See [https://www.elastic.co/guide/en/app-search/current/search-api-precision.html]
  ///
  /// The value of the precision parameter must be an integer between 1 and 11, inclusive.
  /// The range of values represents a sliding scale that manages the inherent tradeoff between precision and recall.
  /// Lower values favor recall, while higher values favor precision.
  @protected
  @JsonKey(name: "precision")
      int? precisionTuning,

  /// Object to delimit the pagination parameters.
  @JsonKey(name: "page")
      _ElasticSearchPage? searchPage,

  /// Object to filter documents that contain a specific field value.
  /// See [https://www.elastic.co/guide/en/app-search/current/filters.html]
  @_ElasticSearchFiltersConverter()
      List<_ElasticSearchFilter>? filters,

  /// Object which restricts a query to search only specific fields.
  @_ElasticSearchFieldsConverter()
  @JsonKey(name: "search_fields")
      List<_ElasticSearchField>? searchFields,

  /// Object to define the fields which appear in search results and how their values are rendered.
  @_ElasticResultFieldsConverter()
  @JsonKey(name: "result_fields")
      List<_ElasticResultField>? resultFields,

  /// Facets are objects which provide the counts of each value or range of values for a field.
  /// See [https://www.elastic.co/guide/en/app-search/current/facets.html]
  @protected
      Map<String, _ElasticQueryFacet>? facets,

  /// Disjunctive facets are useful when you have many filters in your form, and especially
  /// when you filter your query with a value that corresponds to a facet: if a disjunctive facet is set,
  /// it will return all the available facets as if that filter was not applied.
  /// This is not a native part of Elastic App Search, this is a workaround. In fact, multiple queries are
  /// passed to Elastic and the package concatenates all responses in one response.
  @JsonKey(includeToJson: false)
      List<String>? disjunctiveFacets,

  /// Tags can be used to enrich each query with unique information.
  /// See [https://www.elastic.co/guide/en/app-search/current/tags.html]
  _ElasticAnalytics? analytics,

  /// Grouped results based on shared fields
  @protected
  @JsonKey(name: "group")
      _ElasticGroup? groupBy,

  /// Object to sort your results in an order other than document score.
  @_ElasticSortConverter()
  @JsonKey(name: "sort")
      List<_ElasticSort>? sortBy,
}) = _ElasticQuery;