Skip to content

Commit aeaa4bd

Browse files
committed
reworked document tests
1 parent 68266da commit aeaa4bd

File tree

6 files changed

+524
-143
lines changed

6 files changed

+524
-143
lines changed

lib/src/index.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ abstract class MeiliSearchIndex {
7979

8080
/// {@macro meili.add_docs}
8181
///
82-
/// * The passed [documents] must be a valid CSV string, where each line corresponds to an object.
82+
/// *
83+
/// {@template meili.csv}
84+
/// The passed documents must be a valid CSV string, where the first line contains objects' keys and types, and each subsequent line corresponds to an object.
85+
/// [see relevant documentation](https://docs.meilisearch.com/learn/core_concepts/documents.html#csv)
86+
/// {@endtemplate}
87+
///
8388
/// *
8489
/// {@macro meili.index_upsert}
8590
Future<Task> addDocumentsCsv(
@@ -110,7 +115,8 @@ abstract class MeiliSearchIndex {
110115

111116
/// {@macro meili.add_docs_batches}
112117
///
113-
/// * The passed [documents] must be a valid CSV string, where each line corresponds to an object.
118+
/// *
119+
/// {@macro meili.csv}
114120
/// *
115121
/// {@macro meili.index_upsert}
116122
Future<List<Task>> addDocumentsCsvInBatches(
@@ -162,7 +168,8 @@ abstract class MeiliSearchIndex {
162168

163169
/// {@macro meili.update_docs}
164170
///
165-
/// * The passed [documents] must be a valid CSV string, where each line corresponds to an object.
171+
/// *
172+
/// {@macro meili.csv}
166173
/// *
167174
/// {@macro meili.index_upsert}
168175
Future<Task> updateDocumentsCsv(

lib/src/index_impl.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,12 @@ class MeiliSearchIndexImpl implements MeiliSearchIndex {
237237
}) {
238238
final ls = LineSplitter();
239239
final split = ls.convert(documents);
240-
240+
//header is shared for all slices
241+
final header = split.first;
241242
return Future.wait(
242-
split.slices(batchSize).map(
243+
split.skip(1).slices(batchSize).map(
243244
(slice) => addDocumentsCsv(
244-
slice.join('\n'),
245+
[header, ...slice].join('\n'),
245246
primaryKey: primaryKey,
246247
),
247248
),
@@ -343,11 +344,13 @@ class MeiliSearchIndexImpl implements MeiliSearchIndex {
343344
}) {
344345
final ls = LineSplitter();
345346
final split = ls.convert(documents);
347+
//header is shared for all slices
348+
final header = split.first;
346349

347350
return Future.wait(
348-
split.slices(batchSize).map(
351+
split.skip(1).slices(batchSize).map(
349352
(slice) => updateDocumentsCsv(
350-
slice.join('\n'),
353+
[header, ...slice].join('\n'),
351354
primaryKey: primaryKey,
352355
),
353356
),

0 commit comments

Comments
 (0)