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..f304e12b 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 = @@ -457,11 +549,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(); @@ -498,111 +588,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 {