Skip to content

Commit

Permalink
Merge #375
Browse files Browse the repository at this point in the history
375: Changes related to the next Meilisearch release (v1.7.0) r=curquiza a=meili-bot

Related to this issue: meilisearch/integration-guides#296

This PR:
- gathers the changes related to the next Meilisearch release (v1.7.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases).
- might eventually contain test failures until the Meilisearch v1.7.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.7.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._


Co-authored-by: meili-bot <[email protected]>
Co-authored-by: curquiza <[email protected]>
Co-authored-by: Ahmed Fwela <[email protected]>
Co-authored-by: Ahmed Fwela <[email protected]>
Co-authored-by: Clémentine U. - curqui <[email protected]>
  • Loading branch information
5 people authored Mar 11, 2024
2 parents 4c7a4ac + 816b98e commit c9dec3d
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 115 deletions.
6 changes: 0 additions & 6 deletions lib/src/results/experimental_features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> src) {
Expand All @@ -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<String, dynamic> toJson() => _$UpdateExperimentalFeaturesToJson(this);
Expand Down
2 changes: 0 additions & 2 deletions lib/src/results/experimental_features.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

199 changes: 92 additions & 107 deletions test/search_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<MeiliRankingScoreDetailsAttributeRule>()
.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<MeiliRankingScoreDetailsWordsRule>()
.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<MeiliRankingScoreDetailsExactnessRule>()
.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<MeiliRankingScoreDetailsTypoRule>()
.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<MeiliRankingScoreDetailsProximityRule>()
.having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty))
.having((p0) => p0.score, 'score', isNotNull)
.having((p0) => p0.order, 'order', isNotNull);

final rankingScoreDetailsMatcher = isA<MeiliRankingScoreDetails>()
.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<MeiliDocumentContainer<Map<String, dynamic>>>()
.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 =
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<MeiliRankingScoreDetailsAttributeRule>()
// .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<MeiliRankingScoreDetailsWordsRule>()
// .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<MeiliRankingScoreDetailsExactnessRule>()
// .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<MeiliRankingScoreDetailsTypoRule>()
// .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<MeiliRankingScoreDetailsProximityRule>()
// .having((p0) => p0.src, 'src', allOf(isNotNull, isNotEmpty))
// .having((p0) => p0.score, 'score', isNotNull)
// .having((p0) => p0.order, 'order', isNotNull);

// final rankingScoreDetailsMatcher = isA<MeiliRankingScoreDetails>()
// .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<MeiliDocumentContainer<Map<String, dynamic>>>()
// .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 {
Expand Down

0 comments on commit c9dec3d

Please sign in to comment.