Skip to content

Commit 7f813fc

Browse files
meili-bors[bot]meili-botcurquizamdubusbrunoocasali
authored
Merge #1715
1715: Changes related to the next Meilisearch release (v1.11.0) r=brunoocasali a=meili-bot Related to this issue: meilisearch/integration-guides#303 This PR: - gathers the changes related to the next Meilisearch release (v1.11.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.11.0 is out. ⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.11.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: Clémentine <[email protected]> Co-authored-by: Morgane Dubus <[email protected]> Co-authored-by: curquiza <[email protected]> Co-authored-by: Bruno Casali <[email protected]>
2 parents c49c0b5 + 3130931 commit 7f813fc

File tree

7 files changed

+279
-85
lines changed

7 files changed

+279
-85
lines changed

.code-samples.meilisearch.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,19 @@ search_parameter_reference_ranking_score_threshold_1: |-
759759
search_parameter_reference_retrieve_vectors_1: |-
760760
client.index('INDEX_NAME').search('kitchen utensils', {
761761
retrieveVectors: true,
762-
hybrid: { embedder: 'default'}
762+
hybrid: {
763+
embedder: 'EMBEDDER_NAME'
764+
}
765+
})
766+
search_parameter_guide_hybrid_1: |-
767+
client.index('INDEX_NAME').search('kitchen utensils', {
768+
hybrid: {
769+
semanticRatio: 0.9,
770+
embedder: 'EMBEDDER_NAME'
771+
}
763772
})
764773
get_similar_post_1: |-
765-
client.index('INDEX_NAME').searchSimilarDocuments({ id: 'TARGET_DOCUMENT_ID'})
774+
client.index('INDEX_NAME').searchSimilarDocuments({ id: 'TARGET_DOCUMENT_ID', embedder: 'default' })
766775
search_parameter_guide_matching_strategy_3: |-
767776
client.index('movies').search('white shirt', {
768777
matchingStrategy: 'frequency'
@@ -788,7 +797,7 @@ multi_search_federated_1: |-
788797
]
789798
})
790799
search_parameter_reference_locales_1: |-
791-
client.index('INDEX_NAME').search('進撃の巨人', { locales: ['jpn'] })
800+
client.index('INDEX_NAME').search('QUERY TEXT IN JAPANESE', { locales: ['jpn'] })
792801
get_localized_attribute_settings_1: |-
793802
client.index('INDEX_NAME').getLocalizedAttributes()
794803
update_localized_attribute_settings_1: |-

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
services:
2727
meilisearch:
28-
image: getmeili/meilisearch:latest
28+
image: getmeili/meilisearch:v1.11.0
2929
env:
3030
MEILI_MASTER_KEY: 'masterKey'
3131
MEILI_NO_ANALYTICS: 'true'

src/types/types.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export type SearchForFacetValuesResponse = {
9898
};
9999

100100
export type HybridSearch = {
101-
embedder?: string;
101+
embedder: string;
102102
semanticRatio?: number;
103103
};
104104

@@ -153,8 +153,17 @@ export type SearchRequestGET = Pagination &
153153
locales?: Locale[];
154154
};
155155

156+
export type MergeFacets = {
157+
maxValuesPerFacet?: number | null;
158+
};
159+
156160
export type FederationOptions = { weight: number };
157-
export type MultiSearchFederation = { limit?: number; offset?: number };
161+
export type MultiSearchFederation = {
162+
limit?: number;
163+
offset?: number;
164+
facetsByIndex?: Record<string, string[]>;
165+
mergeFacets?: MergeFacets | null;
166+
};
158167

159168
export type MultiSearchQuery = SearchParams & { indexUid: string };
160169
export type MultiSearchQueryWithFederation = MultiSearchQuery & {
@@ -229,6 +238,14 @@ export type Hits<T = Record<string, any>> = Array<Hit<T>>;
229238
export type FacetStat = { min: number; max: number };
230239
export type FacetStats = Record<string, FacetStat>;
231240

241+
export type FacetsByIndex = Record<
242+
string,
243+
{
244+
distribution: FacetDistribution;
245+
stats: FacetStats;
246+
}
247+
>;
248+
232249
export type SearchResponse<
233250
T = Record<string, any>,
234251
S extends SearchParams | undefined = undefined,
@@ -238,6 +255,7 @@ export type SearchResponse<
238255
query: string;
239256
facetDistribution?: FacetDistribution;
240257
facetStats?: FacetStats;
258+
facetsByIndex?: FacetsByIndex;
241259
} & (undefined extends S
242260
? Partial<FinitePagination & InfinitePagination>
243261
: true extends IsFinitePagination<NonNullable<S>>
@@ -389,6 +407,8 @@ export type OpenAiEmbedder = {
389407
dimensions?: number;
390408
distribution?: Distribution;
391409
url?: string;
410+
documentTemplateMaxBytes?: number;
411+
binaryQuantized?: boolean;
392412
};
393413

394414
export type HuggingFaceEmbedder = {
@@ -397,12 +417,15 @@ export type HuggingFaceEmbedder = {
397417
revision?: string;
398418
documentTemplate?: string;
399419
distribution?: Distribution;
420+
documentTemplateMaxBytes?: number;
421+
binaryQuantized?: boolean;
400422
};
401423

402424
export type UserProvidedEmbedder = {
403425
source: "userProvided";
404426
dimensions: number;
405427
distribution?: Distribution;
428+
binaryQuantized?: boolean;
406429
};
407430

408431
export type RestEmbedder = {
@@ -415,6 +438,8 @@ export type RestEmbedder = {
415438
request: Record<string, any>;
416439
response: Record<string, any>;
417440
headers?: Record<string, string>;
441+
documentTemplateMaxBytes?: number;
442+
binaryQuantized?: boolean;
418443
};
419444

420445
export type OllamaEmbedder = {
@@ -425,6 +450,8 @@ export type OllamaEmbedder = {
425450
documentTemplate?: string;
426451
distribution?: Distribution;
427452
dimensions?: number;
453+
documentTemplateMaxBytes?: number;
454+
binaryQuantized?: boolean;
428455
};
429456

430457
export type Embedder =

tests/__snapshots__/settings.test.ts.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ exports[`Test on settings > Admin key: Update embedders settings 1`] = `
249249
"distinctAttribute": null,
250250
"embedders": {
251251
"default": {
252-
"documentTemplate": "{% for field in fields %} {{ field.name }}: {{ field.value }}
253-
{% endfor %}",
252+
"documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}
253+
{% endif %}{% endfor %}",
254+
"documentTemplateMaxBytes": 400,
254255
"model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
255256
"source": "huggingFace",
256257
},
@@ -804,8 +805,9 @@ exports[`Test on settings > Master key: Update embedders settings 1`] = `
804805
"distinctAttribute": null,
805806
"embedders": {
806807
"default": {
807-
"documentTemplate": "{% for field in fields %} {{ field.name }}: {{ field.value }}
808-
{% endfor %}",
808+
"documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}
809+
{% endif %}{% endfor %}",
810+
"documentTemplateMaxBytes": 400,
809811
"model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
810812
"source": "huggingFace",
811813
},

tests/embedders.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
9090
mean: 0.7,
9191
sigma: 0.3,
9292
},
93+
binaryQuantized: false,
9394
},
9495
};
9596
const task: EnqueuedTask = await client
@@ -101,6 +102,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
101102
const response: Embedders = await client.index(index.uid).getEmbedders();
102103

103104
expect(response).toEqual(newEmbedder);
105+
expect(response).not.toHaveProperty("documentTemplateMaxBytes");
104106
});
105107

106108
test(`${permission} key: Update embedders with 'openAi' source`, async () => {
@@ -118,6 +120,8 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
118120
sigma: 0.3,
119121
},
120122
url: "https://api.openai.com/v1/embeddings",
123+
documentTemplateMaxBytes: 500,
124+
binaryQuantized: false,
121125
},
122126
};
123127
const task: EnqueuedTask = await client
@@ -147,6 +151,8 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
147151
mean: 0.7,
148152
sigma: 0.3,
149153
},
154+
documentTemplateMaxBytes: 500,
155+
binaryQuantized: false,
150156
},
151157
};
152158
const task: EnqueuedTask = await client
@@ -188,6 +194,8 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
188194
headers: {
189195
"Custom-Header": "CustomValue",
190196
},
197+
documentTemplateMaxBytes: 500,
198+
binaryQuantized: false,
191199
},
192200
};
193201
const task: EnqueuedTask = await client
@@ -219,6 +227,8 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
219227
sigma: 0.3,
220228
},
221229
dimensions: 512,
230+
documentTemplateMaxBytes: 500,
231+
binaryQuantized: false,
222232
},
223233
};
224234
const task: EnqueuedTask = await client
@@ -266,6 +276,58 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
266276
expect(response).toEqual(null);
267277
});
268278

279+
test(`${permission} key: search (POST) with vectors`, async () => {
280+
const client = await getClient(permission);
281+
282+
const { taskUid } = await client.index(index.uid).updateEmbedders({
283+
default: {
284+
source: "userProvided",
285+
dimensions: 1,
286+
},
287+
});
288+
await client.waitForTask(taskUid);
289+
290+
const response = await client.index(index.uid).search("", {
291+
vector: [1],
292+
hybrid: {
293+
embedder: "default",
294+
semanticRatio: 1.0,
295+
},
296+
});
297+
298+
expect(response).toHaveProperty("hits");
299+
expect(response).toHaveProperty("semanticHitCount");
300+
// Those fields are no longer returned by the search response
301+
// We want to ensure that they don't appear in it anymore
302+
expect(response).not.toHaveProperty("vector");
303+
expect(response).not.toHaveProperty("_semanticScore");
304+
});
305+
306+
test(`${permission} key: search (GET) with vectors`, async () => {
307+
const client = await getClient(permission);
308+
309+
const { taskUid } = await client.index(index.uid).updateEmbedders({
310+
default: {
311+
source: "userProvided",
312+
dimensions: 1,
313+
},
314+
});
315+
await client.waitForTask(taskUid);
316+
317+
const response = await client.index(index.uid).searchGet("", {
318+
vector: [1],
319+
hybridEmbedder: "default",
320+
hybridSemanticRatio: 1.0,
321+
});
322+
323+
expect(response).toHaveProperty("hits");
324+
expect(response).toHaveProperty("semanticHitCount");
325+
// Those fields are no longer returned by the search response
326+
// We want to ensure that they don't appear in it anymore
327+
expect(response).not.toHaveProperty("vector");
328+
expect(response).not.toHaveProperty("_semanticScore");
329+
});
330+
269331
test(`${permission} key: search for similar documents`, async () => {
270332
const client = await getClient(permission);
271333

@@ -288,6 +350,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
288350
await client.waitForTask(documentAdditionTask);
289351

290352
const response = await client.index(index.uid).searchSimilarDocuments({
353+
embedder: "manual",
291354
id: "143",
292355
});
293356

tests/get_search.test.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -457,41 +457,6 @@ describe.each([
457457
"The filter query parameter should be in string format when using searchGet",
458458
);
459459
});
460-
test(`${permission} key: search with vectors`, async () => {
461-
const client = await getClient(permission);
462-
const adminClient = await getClient("Admin");
463-
const adminKey = await getKey("Admin");
464-
465-
await fetch(`${HOST}/experimental-features`, {
466-
body: JSON.stringify({ vectorStore: true }),
467-
headers: {
468-
Authorization: `Bearer ${adminKey}`,
469-
"Content-Type": "application/json",
470-
},
471-
method: "PATCH",
472-
});
473-
474-
const { taskUid } = await adminClient
475-
.index(emptyIndex.uid)
476-
.updateEmbedders({
477-
default: {
478-
source: "userProvided",
479-
dimensions: 1,
480-
},
481-
});
482-
await adminClient.waitForTask(taskUid);
483-
484-
const response = await client
485-
.index(emptyIndex.uid)
486-
.searchGet("", { vector: [1], hybridSemanticRatio: 1.0 });
487-
488-
expect(response).toHaveProperty("hits");
489-
expect(response).toHaveProperty("semanticHitCount");
490-
// Those fields are no longer returned by the search response
491-
// We want to ensure that they don't appear in it anymore
492-
expect(response).not.toHaveProperty("vector");
493-
expect(response).not.toHaveProperty("_semanticScore");
494-
});
495460

496461
test(`${permission} key: search without vectors`, async () => {
497462
const client = await getClient(permission);

0 commit comments

Comments
 (0)