You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/ecommerce.mdx
+31-23
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,18 @@ A breakdown of the script is below
66
66
The first step is to define all the types
67
67
68
68
```ts
69
+
interfaceChunk {
70
+
chunk_html:string;
71
+
link:string;
72
+
tracking_id:string;
73
+
tag_set:string[];
74
+
metadata: {
75
+
[key:string]:string;
76
+
};
77
+
time_stamp:string;
78
+
upsert_by_tracking_id:boolean;
79
+
}
80
+
69
81
interfaceLanguageTaggedValue {
70
82
language_tag:string;
71
83
value:string;
@@ -150,7 +162,7 @@ if (imageHashMap == null) {
150
162
151
163
### Processing a Singular Chunk
152
164
153
-
For each row of json we construct a `CreateChunkData` object, each of which can be pushed into Trieve separately or in bulk. We use the `imageHashMap` object constructed from before to get the `image_url` for each.
165
+
For each row of json we construct a `Chunk` object, each of which can be pushed into Trieve separately or in bulk. We use the `imageHashMap` object constructed from before to get the `image_url` for each.
154
166
155
167
```ts
156
168
function processLine(line:string) {
@@ -206,7 +218,7 @@ function processLine(line: string) {
The last step is we iterate through all the json files, process each line into a CreateChunkData object. We use `chukApi.createChunk` to create chunks, in this case we are sending chunks in a batch size of 120 which is the max for this route.
236
+
The last step is we iterate through all the json files, process each line into a Chunk object. We use the `/chunk` endpoint to create chunks, in this case we are sending chunks in a batch size of 120 which is the max for this route.
console.error("Error parsing JSON from line:", error);
265
271
}
266
272
}
267
273
268
274
const batchSize =120;
269
-
const chunkedItems:CreateChunkData[] = [];
275
+
const chunkedItems:Chunk[][] = [];
270
276
for (let i =0; i<items.length; i+=batchSize) {
271
277
const chunk =items.slice(i, i+batchSize);
272
278
chunkedItems.push(chunk);
@@ -284,3 +290,5 @@ for (const file of files) {
284
290
}
285
291
```
286
292
293
+
Checkout the api reference for the [upload API](/api-reference/chunk/create-or-upsert-chunk-or-chunks) to view all of the parameters that can be passed in with the chunk.
0 commit comments