From 9e17f7d1c707a84c6237cb89618fe2cf41df150d Mon Sep 17 00:00:00 2001 From: meili-bot <74670311+meili-bot@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:44:00 +0100 Subject: [PATCH 1/4] Update README.md From df89d74fe343f2f680ebec2d74c45eacca30128b Mon Sep 17 00:00:00 2001 From: curquiza Date: Fri, 16 Feb 2024 16:10:15 +0100 Subject: [PATCH 2/4] Remove scoreDetails exp feature --- lib/src/results/experimental_features.dart | 6 ------ lib/src/results/experimental_features.g.dart | 2 -- test/search_test.dart | 2 -- 3 files changed, 10 deletions(-) diff --git a/lib/src/results/experimental_features.dart b/lib/src/results/experimental_features.dart index 803d4c03..bc71ec64 100644 --- a/lib/src/results/experimental_features.dart +++ b/lib/src/results/experimental_features.dart @@ -13,12 +13,9 @@ part 'experimental_features.g.dart'; class ExperimentalFeatures { @JsonKey(name: 'vectorStore') final bool vectorStore; - @JsonKey(name: 'scoreDetails') - final bool scoreDetails; const ExperimentalFeatures({ required this.vectorStore, - required this.scoreDetails, }); factory ExperimentalFeatures.fromJson(Map src) { @@ -34,12 +31,9 @@ class ExperimentalFeatures { class UpdateExperimentalFeatures { @JsonKey(name: 'vectorStore') final bool? vectorStore; - @JsonKey(name: 'scoreDetails') - final bool? scoreDetails; const UpdateExperimentalFeatures({ this.vectorStore, - this.scoreDetails, }); Map toJson() => _$UpdateExperimentalFeaturesToJson(this); diff --git a/lib/src/results/experimental_features.g.dart b/lib/src/results/experimental_features.g.dart index 1ca870f6..8dfcaa57 100644 --- a/lib/src/results/experimental_features.g.dart +++ b/lib/src/results/experimental_features.g.dart @@ -10,7 +10,6 @@ ExperimentalFeatures _$ExperimentalFeaturesFromJson( Map json) => ExperimentalFeatures( vectorStore: json['vectorStore'] as bool, - scoreDetails: json['scoreDetails'] as bool, ); Map _$UpdateExperimentalFeaturesToJson( @@ -24,6 +23,5 @@ Map _$UpdateExperimentalFeaturesToJson( } writeNotNull('vectorStore', instance.vectorStore); - writeNotNull('scoreDetails', instance.scoreDetails); return val; } diff --git a/test/search_test.dart b/test/search_test.dart index 939c897b..2d736b91 100644 --- a/test/search_test.dart +++ b/test/search_test.dart @@ -457,11 +457,9 @@ void main() { // setUp(() async { // features = await client.http.updateExperimentalFeatures( // UpdateExperimentalFeatures( - // scoreDetails: true, // vectorStore: true, // ), // ); - // expect(features.scoreDetails, true); // expect(features.vectorStore, true); // uid = randomUid(); From bddcd0026a8d5d8eec3abc13d861f16c105bcd5a Mon Sep 17 00:00:00 2001 From: curquiza Date: Fri, 16 Feb 2024 16:14:32 +0100 Subject: [PATCH 3/4] Add test for showRankingScoreDetails --- test/search_test.dart | 198 ++++++++++++++++++++---------------------- 1 file changed, 93 insertions(+), 105 deletions(-) diff --git a/test/search_test.dart b/test/search_test.dart index 2d736b91..34f40ee3 100644 --- a/test/search_test.dart +++ b/test/search_test.dart @@ -54,6 +54,98 @@ void main() { expect(result.hits, hasLength(1)); }); + test('Show ranking score details', () async { + final res = await index + .search( + 'The', + SearchQuery( + showRankingScore: true, + showRankingScoreDetails: true, + attributesToHighlight: ['*'], + showMatchesPosition: true, + ), + ) + .asSearchResult() + .mapToContainer(); + + final attributeMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having((p0) => p0.queryWordDistanceScore, 'queryWordDistanceScore', + isNotNull) + .having((p0) => p0.attributeRankingOrderScore, + 'attributeRankingOrderScore', isNotNull); + + final wordsMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having((p0) => p0.matchingWords, 'matchingWords', isNotNull) + .having((p0) => p0.maxMatchingWords, 'maxMatchingWords', isNotNull); + + final exactnessMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having( + (p0) => p0.matchType, + 'matchType', + allOf(isNotNull, isNotEmpty), + ); + + final typoMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having((p0) => p0.typoCount, 'typoCount', isNotNull) + .having((p0) => p0.maxTypoCount, 'maxTypoCount', isNotNull); + + final proximityMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull); + + final rankingScoreDetailsMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.attribute, 'attribute', attributeMatcher) + .having((p0) => p0.words, 'words', wordsMatcher) + .having((p0) => p0.exactness, 'exactness', exactnessMatcher) + .having((p0) => p0.typo, 'typo', typoMatcher) + .having((p0) => p0.proximity, 'proximity', proximityMatcher) + .having( + (p0) => p0.customRules, 'customRules', allOf(isNotNull, isEmpty)); + + expect(res.hits.length, 4); + + expect( + res.hits, + everyElement( + isA>>() + .having( + (p0) => p0.parsed, + 'parsed', + isNotEmpty, + ) + .having( + (p0) => p0.src, + 'src', + isNotEmpty, + ) + .having( + (p0) => p0.rankingScore, + 'rankingScore', + isNotNull, + ) + .having( + (p0) => p0.rankingScoreDetails, + 'rankingScoreDetails', + rankingScoreDetailsMatcher, + ), + ), + ); + }); + group('with', () { test('offset parameter', () async { final result = @@ -448,6 +540,7 @@ void main() { }); }); + // Commented because of https://github.com/meilisearch/meilisearch-dart/issues/369 // group('Experimental', () { // setUpClient(); @@ -496,111 +589,6 @@ void main() { // ), // ); // }); - - // test('normal search', () async { - // final res = await index - // .search( - // 'The', - // SearchQuery( - // showRankingScore: true, - // showRankingScoreDetails: true, - // attributesToHighlight: ['*'], - // showMatchesPosition: true, - // ), - // ) - // .asSearchResult() - // .mapToContainer(); - - // final attributeMatcher = isA() - // .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.score, 'score', isNotNull) - // .having((p0) => p0.order, 'order', isNotNull) - // .having((p0) => p0.queryWordDistanceScore, 'queryWordDistanceScore', - // isNotNull) - // .having((p0) => p0.attributeRankingOrderScore, - // 'attributeRankingOrderScore', isNotNull); - - // final wordsMatcher = isA() - // .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.score, 'score', isNotNull) - // .having((p0) => p0.order, 'order', isNotNull) - // .having((p0) => p0.matchingWords, 'matchingWords', isNotNull) - // .having((p0) => p0.maxMatchingWords, 'maxMatchingWords', isNotNull); - - // final exactnessMatcher = isA() - // .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.score, 'score', isNotNull) - // .having((p0) => p0.order, 'order', isNotNull) - // .having( - // (p0) => p0.matchType, - // 'matchType', - // allOf(isNotNull, isNotEmpty), - // ); - - // final typoMatcher = isA() - // .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.score, 'score', isNotNull) - // .having((p0) => p0.order, 'order', isNotNull) - // .having((p0) => p0.typoCount, 'typoCount', isNotNull) - // .having((p0) => p0.maxTypoCount, 'maxTypoCount', isNotNull); - - // final proximityMatcher = isA() - // .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.score, 'score', isNotNull) - // .having((p0) => p0.order, 'order', isNotNull); - - // final rankingScoreDetailsMatcher = isA() - // .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.attribute, 'attribute', attributeMatcher) - // .having((p0) => p0.words, 'words', wordsMatcher) - // .having((p0) => p0.exactness, 'exactness', exactnessMatcher) - // .having((p0) => p0.typo, 'typo', typoMatcher) - // .having((p0) => p0.proximity, 'proximity', proximityMatcher) - // .having( - // (p0) => p0.customRules, 'customRules', allOf(isNotNull, isEmpty)); - - // expect(res.hits.length, 2); - - // expect( - // res.hits, - // everyElement( - // isA>>() - // .having( - // (p0) => p0.formatted, - // 'formatted', - // allOf(isNotNull, isNotEmpty, contains('id')), - // ) - // .having( - // (p0) => p0.matchesPosition, - // 'matchesPosition', - // allOf(isNotNull, isNotEmpty, containsPair('title', isNotEmpty)), - // ) - // .having( - // (p0) => p0.parsed, - // 'parsed', - // isNotEmpty, - // ) - // .having( - // (p0) => p0.src, - // 'src', - // isNotEmpty, - // ) - // .having( - // (p0) => p0.rankingScore, - // 'rankingScore', - // isNotNull, - // ) - // .having( - // (p0) => p0.rankingScoreDetails, - // 'rankingScoreDetails', - // rankingScoreDetailsMatcher, - // ) - // .having( - // (p0) => p0.vectors, 'vectors', allOf(isNotNull, isNotEmpty)) - // .having((p0) => p0.semanticScore, 'semanticScore', isNull), - // ), - // ); - // }); // }); test('search code samples', () async { From 194514a76804ec2e967a2b3b8724c17d366b2949 Mon Sep 17 00:00:00 2001 From: Ahmed Fwela Date: Fri, 16 Feb 2024 18:40:09 +0200 Subject: [PATCH 4/4] format --- test/search_test.dart | 179 +++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 90 deletions(-) diff --git a/test/search_test.dart b/test/search_test.dart index 34f40ee3..f304e12b 100644 --- a/test/search_test.dart +++ b/test/search_test.dart @@ -55,96 +55,96 @@ void main() { }); test('Show ranking score details', () async { - final res = await index - .search( - 'The', - SearchQuery( - showRankingScore: true, - showRankingScoreDetails: true, - attributesToHighlight: ['*'], - showMatchesPosition: true, - ), - ) - .asSearchResult() - .mapToContainer(); - - final attributeMatcher = isA() - .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - .having((p0) => p0.score, 'score', isNotNull) - .having((p0) => p0.order, 'order', isNotNull) - .having((p0) => p0.queryWordDistanceScore, 'queryWordDistanceScore', - isNotNull) - .having((p0) => p0.attributeRankingOrderScore, - 'attributeRankingOrderScore', isNotNull); - - final wordsMatcher = isA() - .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - .having((p0) => p0.score, 'score', isNotNull) - .having((p0) => p0.order, 'order', isNotNull) - .having((p0) => p0.matchingWords, 'matchingWords', isNotNull) - .having((p0) => p0.maxMatchingWords, 'maxMatchingWords', isNotNull); - - final exactnessMatcher = isA() - .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - .having((p0) => p0.score, 'score', isNotNull) - .having((p0) => p0.order, 'order', isNotNull) - .having( - (p0) => p0.matchType, - 'matchType', - allOf(isNotNull, isNotEmpty), - ); - - final typoMatcher = isA() - .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - .having((p0) => p0.score, 'score', isNotNull) - .having((p0) => p0.order, 'order', isNotNull) - .having((p0) => p0.typoCount, 'typoCount', isNotNull) - .having((p0) => p0.maxTypoCount, 'maxTypoCount', isNotNull); - - final proximityMatcher = isA() - .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - .having((p0) => p0.score, 'score', isNotNull) - .having((p0) => p0.order, 'order', isNotNull); - - final rankingScoreDetailsMatcher = isA() - .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) - .having((p0) => p0.attribute, 'attribute', attributeMatcher) - .having((p0) => p0.words, 'words', wordsMatcher) - .having((p0) => p0.exactness, 'exactness', exactnessMatcher) - .having((p0) => p0.typo, 'typo', typoMatcher) - .having((p0) => p0.proximity, 'proximity', proximityMatcher) - .having( - (p0) => p0.customRules, 'customRules', allOf(isNotNull, isEmpty)); - - expect(res.hits.length, 4); - - expect( - res.hits, - everyElement( - isA>>() - .having( - (p0) => p0.parsed, - 'parsed', - isNotEmpty, - ) - .having( - (p0) => p0.src, - 'src', - isNotEmpty, - ) - .having( - (p0) => p0.rankingScore, - 'rankingScore', - isNotNull, - ) - .having( - (p0) => p0.rankingScoreDetails, - 'rankingScoreDetails', - rankingScoreDetailsMatcher, + final res = await index + .search( + 'The', + SearchQuery( + showRankingScore: true, + showRankingScoreDetails: true, + attributesToHighlight: ['*'], + showMatchesPosition: true, ), - ), - ); - }); + ) + .asSearchResult() + .mapToContainer(); + + final attributeMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having((p0) => p0.queryWordDistanceScore, 'queryWordDistanceScore', + isNotNull) + .having((p0) => p0.attributeRankingOrderScore, + 'attributeRankingOrderScore', isNotNull); + + final wordsMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having((p0) => p0.matchingWords, 'matchingWords', isNotNull) + .having((p0) => p0.maxMatchingWords, 'maxMatchingWords', isNotNull); + + final exactnessMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having( + (p0) => p0.matchType, + 'matchType', + allOf(isNotNull, isNotEmpty), + ); + + final typoMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull) + .having((p0) => p0.typoCount, 'typoCount', isNotNull) + .having((p0) => p0.maxTypoCount, 'maxTypoCount', isNotNull); + + final proximityMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.score, 'score', isNotNull) + .having((p0) => p0.order, 'order', isNotNull); + + final rankingScoreDetailsMatcher = isA() + .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty)) + .having((p0) => p0.attribute, 'attribute', attributeMatcher) + .having((p0) => p0.words, 'words', wordsMatcher) + .having((p0) => p0.exactness, 'exactness', exactnessMatcher) + .having((p0) => p0.typo, 'typo', typoMatcher) + .having((p0) => p0.proximity, 'proximity', proximityMatcher) + .having((p0) => p0.customRules, 'customRules', + allOf(isNotNull, isEmpty)); + + expect(res.hits.length, 4); + + expect( + res.hits, + everyElement( + isA>>() + .having( + (p0) => p0.parsed, + 'parsed', + isNotEmpty, + ) + .having( + (p0) => p0.src, + 'src', + isNotEmpty, + ) + .having( + (p0) => p0.rankingScore, + 'rankingScore', + isNotNull, + ) + .having( + (p0) => p0.rankingScoreDetails, + 'rankingScoreDetails', + rankingScoreDetailsMatcher, + ), + ), + ); + }); group('with', () { test('offset parameter', () async { @@ -540,7 +540,6 @@ void main() { }); }); - // Commented because of https://github.com/meilisearch/meilisearch-dart/issues/369 // group('Experimental', () { // setUpClient();