-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Result container #350
Add Result container #350
Conversation
…atures` to MeiliSearchClient
…anking rule details
…urned search result. feat(search): added experimental vector. feat(search): added `mapToContainer` extension on Searcheable<T> and its children, to simplify wrapping documents.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #350 +/- ##
==========================================
- Coverage 82.84% 82.03% -0.81%
==========================================
Files 48 57 +9
Lines 1218 1353 +135
==========================================
+ Hits 1009 1110 +101
- Misses 209 243 +34
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments to help reviewers :)
@@ -71,9 +71,9 @@ Each PR should pass the tests and the linter to be accepted. | |||
# Tests | |||
curl -L https://install.meilisearch.com | sh # download Meilisearch | |||
./meilisearch --master-key=masterKey --no-analytics # run Meilisearch | |||
pub run test --concurrency=4 | |||
dart test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dart test
by default uses concurrency
@@ -62,6 +65,9 @@ class IndexSearchQuery extends SearchQuery { | |||
String? highlightPostTag, | |||
MatchingStrategy? matchingStrategy, | |||
List<String>? attributesToSearchOn, | |||
bool? showRankingScore, | |||
List<dynamic /* double | List<double> */ >? vector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wish dart had type unions 😢
final MeiliRankingScoreDetails? rankingScoreDetails; | ||
|
||
/// Contains the location of each occurrence of queried terms across all fields | ||
final Map<String, List<MatchPosition>>? matchesPosition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was incorrectly placed in Searcheable<T>
dynamic operator [](String key) => src[key]; | ||
dynamic getFormatted(String key) => formatted?[key]; | ||
|
||
dynamic getFormattedOrSrc(String key) => getFormatted(key) ?? this[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convenience methods
for (var custom in src.entries | ||
.where((element) => !reservedKeys.contains(element.key))) | ||
custom.key: MeiliRankingScoreDetailsCustomRule.fromJson( | ||
custom.value as Map<String, dynamic>, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had a chance to test this, since I have no idea when a custom rule is returned
this.scoreDetails, | ||
}); | ||
|
||
Map<String, dynamic> toJson() => _$UpdateExperimentalFeaturesToJson(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is generated using json_serializable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this entire file is generated using json_serializable
@@ -40,6 +33,7 @@ class PaginatedSearchResult<T> extends Searcheable<T> { | |||
String? indexUid, | |||
}) { | |||
return PaginatedSearchResult( | |||
src: map, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we pass the original map here, if users want access to the raw response.
/// - `exactMatch`: the document contains an attribute that exactly matches the query. | ||
/// - `matchesStart`: the document contains an attribute that exactly starts with the query. | ||
/// - `noExactMatch`: any other document. | ||
final String matchType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use an enum here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small remark about the experimental methods, otherwise I think we are good to go!
lib/src/client.dart
Outdated
@@ -125,6 +125,35 @@ class MeiliSearchClient { | |||
return Task.fromMap(response.data!); | |||
} | |||
|
|||
/// Get the status of all experimental features that can be toggled at runtime | |||
@RequiredMeiliServerVersion('1.3.0') | |||
Future<ExperimentalFeatures> getExperimentalFeatures() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did not provide these kinds of methods to the other SDKs. I understand they are very convenient during development but we believe they are not useful after that, since you only enable/disable once :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can mark them as internal as a warning to users to not use this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's ok to keep, my concern is because it is more code to maintain and it will be present only in this SDK :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 🎉 🎉
bors merge
Build succeeded:
|
Pull Request
Related issue
Fixes #335
Fixes #337
Fixes #338
Starts work on #276
What does this PR do?
In this PR the main feature is adding
MeiliDocumentContainer<T>
, which wraps around documents returned by meilisearch and adds typed, useful information to them.I have also added a dependency on json_serializable to generate serialization information for models (
toJson
+fromJson
), but I will be rolling all models gradually.Here is the complete list of changes:
CONTRIBUTING.md
to include instructions on generatingjson_serializable
files.getExperimentalFeatures
andupdateExperimentalFeatures
toMeiliSearchClient
SearchQuery
andIndexSearchQuery
3.1.
List? vector
3.2.
bool? showRankingScore
3.3.
bool? showRankingScoreDetails
MeiliDocumentContainer<T>
Map<String, dynamic> src
to Searcheable, which exposes the raw json object returned from the server.REASON: just in case we don't keep up with new meilisearch releases, the user has a way to access new features.
Searcheable<T>
had a wrongmatchesPosition
property, which I have moved intoMeiliDocumentContainer<T>
Searcheable<T>
constructor asrequired
REASON: just in case we forget to add them in
PaginatedSearchResult<T>
orSearchResult<T>
PR checklist
Please check if your PR fulfills the following requirements:
.code-samples.meilisearch.yml
filesThank you so much for contributing to Meilisearch!