Skip to content

Commit 4e5e70b

Browse files
authored
feat: hybrid search improvements for v1.8.x (#1647)
1 parent 0dc6d90 commit 4e5e70b

File tree

6 files changed

+419
-4
lines changed

6 files changed

+419
-4
lines changed

src/types/types.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ export type SearchResponse<
215215
query: string
216216
facetDistribution?: FacetDistribution
217217
facetStats?: FacetStats
218-
vector?: number[]
219218
} & (undefined extends S
220219
? Partial<FinitePagination & InfinitePagination>
221220
: true extends IsFinitePagination<NonNullable<S>>
@@ -335,30 +334,63 @@ export type NonSeparatorTokens = string[] | null
335334
export type Dictionary = string[] | null
336335
export type ProximityPrecision = 'byWord' | 'byAttribute'
337336

337+
export type Distribution = {
338+
mean: number
339+
sigma: number
340+
}
341+
338342
export type OpenAiEmbedder = {
339343
source: 'openAi'
340344
model?: string
341345
apiKey?: string
342346
documentTemplate?: string
343347
dimensions?: number
348+
distribution?: Distribution
344349
}
345350

346351
export type HuggingFaceEmbedder = {
347352
source: 'huggingFace'
348353
model?: string
349354
revision?: string
350355
documentTemplate?: string
356+
distribution?: Distribution
351357
}
352358

353359
export type UserProvidedEmbedder = {
354360
source: 'userProvided'
355361
dimensions: number
362+
distribution?: Distribution
363+
}
364+
365+
export type RestEmbedder = {
366+
source: 'rest'
367+
url: string
368+
apiKey?: string
369+
dimensions?: number
370+
documentTemplate?: string
371+
inputField?: string[] | null
372+
inputType?: 'text' | 'textArray'
373+
query?: Record<string, any> | null
374+
pathToEmbeddings?: string[] | null
375+
embeddingObject?: string[] | null
376+
distribution?: Distribution
377+
}
378+
379+
export type OllamaEmbedder = {
380+
source: 'ollama'
381+
url?: string
382+
apiKey?: string
383+
model?: string
384+
documentTemplate?: string
385+
distribution?: Distribution
356386
}
357387

358388
export type Embedder =
359389
| OpenAiEmbedder
360390
| HuggingFaceEmbedder
361391
| UserProvidedEmbedder
392+
| RestEmbedder
393+
| OllamaEmbedder
362394
| null
363395

364396
export type Embedders = Record<string, Embedder> | null

tests/__snapshots__/settings.test.ts.snap

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,53 @@ exports[`Test on settings Admin key: Get default settings of empty index with pr
9494
}
9595
`;
9696

97+
exports[`Test on settings Admin key: Reset embedders settings 1`] = `
98+
{
99+
"dictionary": [],
100+
"displayedAttributes": [
101+
"*",
102+
],
103+
"distinctAttribute": null,
104+
"faceting": {
105+
"maxValuesPerFacet": 100,
106+
"sortFacetValuesBy": {
107+
"*": "alpha",
108+
},
109+
},
110+
"filterableAttributes": [],
111+
"nonSeparatorTokens": [],
112+
"pagination": {
113+
"maxTotalHits": 1000,
114+
},
115+
"proximityPrecision": "byWord",
116+
"rankingRules": [
117+
"words",
118+
"typo",
119+
"proximity",
120+
"attribute",
121+
"sort",
122+
"exactness",
123+
],
124+
"searchCutoffMs": null,
125+
"searchableAttributes": [
126+
"*",
127+
],
128+
"separatorTokens": [],
129+
"sortableAttributes": [],
130+
"stopWords": [],
131+
"synonyms": {},
132+
"typoTolerance": {
133+
"disableOnAttributes": [],
134+
"disableOnWords": [],
135+
"enabled": true,
136+
"minWordSizeForTypos": {
137+
"oneTypo": 5,
138+
"twoTypos": 9,
139+
},
140+
},
141+
}
142+
`;
143+
97144
exports[`Test on settings Admin key: Reset settings 1`] = `
98145
{
99146
"dictionary": [],
@@ -188,6 +235,66 @@ exports[`Test on settings Admin key: Reset settings of empty index 1`] = `
188235
}
189236
`;
190237

238+
exports[`Test on settings Admin key: Update embedders settings 1`] = `
239+
{
240+
"dictionary": [],
241+
"displayedAttributes": [
242+
"*",
243+
],
244+
"distinctAttribute": null,
245+
"embedders": {
246+
"default": {
247+
"apiKey": "<yoXXXXX...",
248+
"dimensions": 1536,
249+
"distribution": {
250+
"mean": 0.7,
251+
"sigma": 0.3,
252+
},
253+
"documentTemplate": "A document template",
254+
"model": "text-embedding-3-small",
255+
"source": "openAi",
256+
},
257+
},
258+
"faceting": {
259+
"maxValuesPerFacet": 100,
260+
"sortFacetValuesBy": {
261+
"*": "alpha",
262+
},
263+
},
264+
"filterableAttributes": [],
265+
"nonSeparatorTokens": [],
266+
"pagination": {
267+
"maxTotalHits": 1000,
268+
},
269+
"proximityPrecision": "byWord",
270+
"rankingRules": [
271+
"words",
272+
"typo",
273+
"proximity",
274+
"attribute",
275+
"sort",
276+
"exactness",
277+
],
278+
"searchCutoffMs": null,
279+
"searchableAttributes": [
280+
"*",
281+
],
282+
"separatorTokens": [],
283+
"sortableAttributes": [],
284+
"stopWords": [],
285+
"synonyms": {},
286+
"typoTolerance": {
287+
"disableOnAttributes": [],
288+
"disableOnWords": [],
289+
"enabled": true,
290+
"minWordSizeForTypos": {
291+
"oneTypo": 5,
292+
"twoTypos": 9,
293+
},
294+
},
295+
}
296+
`;
297+
191298
exports[`Test on settings Admin key: Update searchableAttributes settings on empty index 1`] = `
192299
{
193300
"dictionary": [],
@@ -536,6 +643,53 @@ exports[`Test on settings Master key: Get default settings of empty index with p
536643
}
537644
`;
538645

646+
exports[`Test on settings Master key: Reset embedders settings 1`] = `
647+
{
648+
"dictionary": [],
649+
"displayedAttributes": [
650+
"*",
651+
],
652+
"distinctAttribute": null,
653+
"faceting": {
654+
"maxValuesPerFacet": 100,
655+
"sortFacetValuesBy": {
656+
"*": "alpha",
657+
},
658+
},
659+
"filterableAttributes": [],
660+
"nonSeparatorTokens": [],
661+
"pagination": {
662+
"maxTotalHits": 1000,
663+
},
664+
"proximityPrecision": "byWord",
665+
"rankingRules": [
666+
"words",
667+
"typo",
668+
"proximity",
669+
"attribute",
670+
"sort",
671+
"exactness",
672+
],
673+
"searchCutoffMs": null,
674+
"searchableAttributes": [
675+
"*",
676+
],
677+
"separatorTokens": [],
678+
"sortableAttributes": [],
679+
"stopWords": [],
680+
"synonyms": {},
681+
"typoTolerance": {
682+
"disableOnAttributes": [],
683+
"disableOnWords": [],
684+
"enabled": true,
685+
"minWordSizeForTypos": {
686+
"oneTypo": 5,
687+
"twoTypos": 9,
688+
},
689+
},
690+
}
691+
`;
692+
539693
exports[`Test on settings Master key: Reset settings 1`] = `
540694
{
541695
"dictionary": [],
@@ -630,6 +784,66 @@ exports[`Test on settings Master key: Reset settings of empty index 1`] = `
630784
}
631785
`;
632786

787+
exports[`Test on settings Master key: Update embedders settings 1`] = `
788+
{
789+
"dictionary": [],
790+
"displayedAttributes": [
791+
"*",
792+
],
793+
"distinctAttribute": null,
794+
"embedders": {
795+
"default": {
796+
"apiKey": "<yoXXXXX...",
797+
"dimensions": 1536,
798+
"distribution": {
799+
"mean": 0.7,
800+
"sigma": 0.3,
801+
},
802+
"documentTemplate": "A document template",
803+
"model": "text-embedding-3-small",
804+
"source": "openAi",
805+
},
806+
},
807+
"faceting": {
808+
"maxValuesPerFacet": 100,
809+
"sortFacetValuesBy": {
810+
"*": "alpha",
811+
},
812+
},
813+
"filterableAttributes": [],
814+
"nonSeparatorTokens": [],
815+
"pagination": {
816+
"maxTotalHits": 1000,
817+
},
818+
"proximityPrecision": "byWord",
819+
"rankingRules": [
820+
"words",
821+
"typo",
822+
"proximity",
823+
"attribute",
824+
"sort",
825+
"exactness",
826+
],
827+
"searchCutoffMs": null,
828+
"searchableAttributes": [
829+
"*",
830+
],
831+
"separatorTokens": [],
832+
"sortableAttributes": [],
833+
"stopWords": [],
834+
"synonyms": {},
835+
"typoTolerance": {
836+
"disableOnAttributes": [],
837+
"disableOnWords": [],
838+
"enabled": true,
839+
"minWordSizeForTypos": {
840+
"oneTypo": 5,
841+
"twoTypos": 9,
842+
},
843+
},
844+
}
845+
`;
846+
633847
exports[`Test on settings Master key: Update searchableAttributes settings on empty index 1`] = `
634848
{
635849
"dictionary": [],

0 commit comments

Comments
 (0)