Skip to content

Commit

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

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

This PR:
- gathers the changes related to the next Meilisearch release (v1.13) 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.13 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.13) 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: Strift <[email protected]>
Co-authored-by: meili-bors[bot] <89034592+meili-bors[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 18, 2025
2 parents dca48cd + 5d47dbf commit 11a76bc
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ["3.0.0"]
version: ['latest']
name: integration-tests-against-rc (dart ${{ matrix.version }})
steps:
- name: Checkout
Expand Down
14 changes: 2 additions & 12 deletions lib/src/results/experimental_features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ part 'experimental_features.g.dart';
createToJson: false,
)
class ExperimentalFeatures {
@JsonKey(name: 'vectorStore')
final bool vectorStore;

const ExperimentalFeatures({
required this.vectorStore,
});
const ExperimentalFeatures();

factory ExperimentalFeatures.fromJson(Map<String, dynamic> src) {
return _$ExperimentalFeaturesFromJson(src);
Expand All @@ -29,12 +24,7 @@ class ExperimentalFeatures {
createFactory: false,
)
class UpdateExperimentalFeatures {
@JsonKey(name: 'vectorStore')
final bool? vectorStore;

const UpdateExperimentalFeatures({
this.vectorStore,
});
const UpdateExperimentalFeatures();

Map<String, dynamic> toJson() => _$UpdateExperimentalFeaturesToJson(this);
}
Expand Down
18 changes: 3 additions & 15 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.

59 changes: 32 additions & 27 deletions test/search_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:meilisearch/meilisearch.dart';
import 'package:meilisearch/src/results/experimental_features.dart';
import 'package:test/test.dart';

import 'utils/books.dart';
Expand All @@ -8,6 +7,8 @@ import 'utils/client.dart';
import 'utils/wait_for.dart';

void main() {
final openAiKeyValue = openAiKey;

group('Search', () {
setUpClient();
late String uid;
Expand Down Expand Up @@ -542,55 +543,62 @@ void main() {
});

// Commented because of https://github.com/meilisearch/meilisearch-dart/issues/369
group('Experimental', () {
group('Vector search', () {
setUpClient();
late String uid;
late MeiliSearchIndex index;
late ExperimentalFeatures features;
setUp(() async {
features = await client.http.updateExperimentalFeatures(
UpdateExperimentalFeatures(
vectorStore: true,
late IndexSettings settings;

setUpAll(() {
settings = IndexSettings(embedders: {
'default': OpenAiEmbedder(
model: 'text-embedding-3-small',
apiKey: openAiKeyValue,
documentTemplate: "a book titled '{{ doc.title }}'",
),
);
expect(features.vectorStore, true);
});
});

setUp(() async {
uid = randomUid();
index = await createIndexWithData(uid: uid, data: vectorBooks);
// Configure embedder before running vector search
await index.updateSettings(settings).waitFor(client: client);
});

test('vector search', () async {
final vector = [0, 1, 2];
// Create a vector with 1536 dimensions (filled with zeros for test purposes)
final vector = List.filled(1536, 0.0);
final res = await index
.search(
null,
SearchQuery(
vector: vector,
hybrid: HybridSearch(
embedder: 'default',
semanticRatio: 1.0,
),
),
)
.asSearchResult()
.mapToContainer();

expect(res.vector, vector);
expect(
res.hits,
everyElement(
isA<MeiliDocumentContainer<Map<String, dynamic>>>()
.having(
(p0) => p0.vectors,
'vectors',
isNotNull,
)
.having(
(p0) => p0.semanticScore,
'semanticScore',
isNotNull,
),
isA<MeiliDocumentContainer<Map<String, dynamic>>>().having(
(p0) => p0.parsed,
'parsed',
isNotNull,
),
),
);
});
}, skip: "Requires Experimental API");
final openAiKeyValue = openAiKey;
},
skip: openAiKeyValue == null || openAiKeyValue.isEmpty
? "Requires OPEN_AI_API_KEY environment variable"
: null);

group('Embedders', () {
group(
'Unit test',
Expand Down Expand Up @@ -665,9 +673,6 @@ void main() {
});

setUp(() async {
final features = await client.http.updateExperimentalFeatures(
UpdateExperimentalFeatures(vectorStore: true));
expect(features.vectorStore, true);
uid = randomUid();
index = await createBooksIndex(uid: uid);
});
Expand Down
30 changes: 25 additions & 5 deletions test/utils/books_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,43 @@ final vectorBooks = [
{
"id": 0,
"title": "Across The Universe",
"_vectors": [0, 0.8, -0.2],
"_vectors": {
"default": {
"embeddings": [0, 0.8, -0.2],
"regenerate": false,
}
}
},
{
"id": 1,
"title": "All Things Must Pass",
"_vectors": [1, -0.2, 0],
"_vectors": {
"default": {
"embeddings": [1, -0.2, 0],
"regenerate": false,
}
}
},
{
"id": 2,
"title": "And Your Bird Can Sing",
"_vectors": [-0.2, 4, 6],
"_vectors": {
"default": {
"embeddings": [-0.2, 4, 6],
"regenerate": false,
}
}
},
{
"id": 3,
"title": "The Matrix",
"_vectors": [5, -0.5, 0.3],
},
"_vectors": {
"default": {
"embeddings": [5, -0.5, 0.3],
"regenerate": false,
}
},
}
];

enum CSVHeaderTypes {
Expand Down

0 comments on commit 11a76bc

Please sign in to comment.