Skip to content

Commit

Permalink
Apply changes in the search requests/responses (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali authored Jun 20, 2022
1 parent 90d8de5 commit b133c30
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ search_parameter_guide_highlight_1: |-
.index('movies')
.search('winter feast', attributesToHighlight: ['overview']);
search_parameter_guide_matches_1: |-
await client.index('movies').search('winter feast', matches: true);
await client.index('movies').search('winter feast', showMatchesPosition: true);
settings_guide_synonyms_1: |-
await client.index('tops').updateSettings(IndexSettings(synonyms: {
'sweater': ['jumper'],
Expand Down Expand Up @@ -345,7 +345,7 @@ faceted_search_filter_1: |-
'director = "Jordan Peele"'
]);
faceted_search_facets_distribution_1: |-
await client.index('movies').search('Batman', facetsDistribution: ['genres']);
await client.index('movies').search('Batman', facets: ['genres']);
faceted_search_walkthrough_filter_1: |-
await client.index('movies').search('thriller', filter: [
['genres = Horror', 'genres = Mystery'],
Expand Down
4 changes: 2 additions & 2 deletions lib/src/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ abstract class MeiliSearchIndex {
int? limit,
dynamic filter,
List<String>? sort,
List<String>? facetsDistribution,
List<String>? facets,
List<String>? attributesToRetrieve,
List<String>? attributesToCrop,
int? cropLength,
List<String>? attributesToHighlight,
bool? matches,
bool? showMatchesPosition,
String? cropMarker,
String? highlightPreTag,
String? highlightPostTag,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/index_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ class MeiliSearchIndexImpl implements MeiliSearchIndex {
int? limit,
dynamic filter,
List<String>? sort,
List<String>? facetsDistribution,
List<String>? facets,
List<String>? attributesToRetrieve,
List<String>? attributesToCrop,
int? cropLength,
List<String>? attributesToHighlight,
bool? matches,
bool? showMatchesPosition,
String? cropMarker,
String? highlightPreTag,
String? highlightPostTag,
Expand All @@ -125,12 +125,12 @@ class MeiliSearchIndexImpl implements MeiliSearchIndex {
'limit': limit,
'filter': filter,
'sort': sort,
'facetsDistribution': facetsDistribution,
'facets': facets,
'attributesToRetrieve': attributesToRetrieve,
'attributesToCrop': attributesToCrop,
'cropLength': cropLength,
'attributesToHighlight': attributesToHighlight,
'matches': matches,
'showMatchesPosition': showMatchesPosition,
'cropMarker': cropMarker,
'highlightPreTag': highlightPreTag,
'highlightPostTag': highlightPostTag,
Expand Down
22 changes: 6 additions & 16 deletions lib/src/search_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ class SearchResult {
this.limit,
this.processingTimeMs,
this.query,
this.nbHits,
this.exhaustiveNbHits,
this.facetsDistribution,
this.exhaustiveFacetsCount,
this.estimatedTotalHits,
this.facetDistribution,
});

/// Results of the query
Expand All @@ -24,16 +22,10 @@ class SearchResult {
final int? processingTimeMs;

/// Total number of matches
final int? nbHits;

/// Whether [nbHits] is exhaustive
final bool? exhaustiveNbHits;
final int? estimatedTotalHits;

/// Distribution of the given facets
final dynamic facetsDistribution;

/// Whether [facetsDistribution] is exhaustive
final bool? exhaustiveFacetsCount;
final dynamic facetDistribution;

/// Query originating the response
final String? query;
Expand All @@ -45,10 +37,8 @@ class SearchResult {
limit: map['limit'] as int?,
offset: map['offset'] as int?,
processingTimeMs: map['processingTimeMs'] as int?,
nbHits: map['nbHits'] as int?,
exhaustiveNbHits: map['exhaustiveNbHits'] as bool?,
facetsDistribution: map['facetsDistribution'] as dynamic,
exhaustiveFacetsCount: map['exhaustiveFacetsCount'] as bool?,
estimatedTotalHits: map['estimatedTotalHits'] as int?,
facetDistribution: map['facetDistribution'] as dynamic,
);
}
}
2 changes: 1 addition & 1 deletion test/search_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void main() {
))
.waitFor();
expect(response.status, 'succeeded');
var result = await index.search('prince', facetsDistribution: ['*']);
var result = await index.search('prince', facets: ['*']);
expect(result.hits, hasLength(2));
});

Expand Down

0 comments on commit b133c30

Please sign in to comment.