From b133c303d556550f9781a9a13d603369a0077f50 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Mon, 20 Jun 2022 06:43:13 -0300 Subject: [PATCH] Apply changes in the search requests/responses (#175) --- .code-samples.meilisearch.yaml | 4 ++-- lib/src/index.dart | 4 ++-- lib/src/index_impl.dart | 8 ++++---- lib/src/search_result.dart | 22 ++++++---------------- test/search_test.dart | 2 +- 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 34e109f1..eb47ef58 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -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'], @@ -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'], diff --git a/lib/src/index.dart b/lib/src/index.dart index 3a21aadc..6e822812 100644 --- a/lib/src/index.dart +++ b/lib/src/index.dart @@ -26,12 +26,12 @@ abstract class MeiliSearchIndex { int? limit, dynamic filter, List? sort, - List? facetsDistribution, + List? facets, List? attributesToRetrieve, List? attributesToCrop, int? cropLength, List? attributesToHighlight, - bool? matches, + bool? showMatchesPosition, String? cropMarker, String? highlightPreTag, String? highlightPostTag, diff --git a/lib/src/index_impl.dart b/lib/src/index_impl.dart index 151bec8c..bf84c234 100644 --- a/lib/src/index_impl.dart +++ b/lib/src/index_impl.dart @@ -109,12 +109,12 @@ class MeiliSearchIndexImpl implements MeiliSearchIndex { int? limit, dynamic filter, List? sort, - List? facetsDistribution, + List? facets, List? attributesToRetrieve, List? attributesToCrop, int? cropLength, List? attributesToHighlight, - bool? matches, + bool? showMatchesPosition, String? cropMarker, String? highlightPreTag, String? highlightPostTag, @@ -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, diff --git a/lib/src/search_result.dart b/lib/src/search_result.dart index 856b7331..fb1920fd 100644 --- a/lib/src/search_result.dart +++ b/lib/src/search_result.dart @@ -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 @@ -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; @@ -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, ); } } diff --git a/test/search_test.dart b/test/search_test.dart index 2472678e..cf081505 100644 --- a/test/search_test.dart +++ b/test/search_test.dart @@ -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)); });