File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,9 @@ export type SearchParams = Query &
130130 hybrid ?: HybridSearch ;
131131 distinct ?: string ;
132132 retrieveVectors ?: boolean ;
133+ // @TODO : Either explicitly type this (that implies keeping it up to date),
134+ // or link to the docs where the available locales are listed
135+ locales ?: string [ ] ;
133136 } ;
134137
135138// Search parameters for searches made with the GET method
@@ -428,6 +431,14 @@ export type PaginationSettings = {
428431
429432export type SearchCutoffMs = number | null ;
430433
434+ export type LocalizedAttribute = {
435+ attributePatterns : string [ ] ;
436+ // @TODO : Type or link to docs
437+ locales : string [ ] ;
438+ } ;
439+
440+ export type LocalizedAttributes = LocalizedAttribute [ ] | null ;
441+
431442export type Settings = {
432443 filterableAttributes ?: FilterableAttributes ;
433444 distinctAttribute ?: DistinctAttribute ;
@@ -446,6 +457,7 @@ export type Settings = {
446457 proximityPrecision ?: ProximityPrecision ;
447458 embedders ?: Embedders ;
448459 searchCutoffMs ?: SearchCutoffMs ;
460+ localizedAttributes ?: LocalizedAttributes ;
449461} ;
450462
451463/*
Original file line number Diff line number Diff line change @@ -992,6 +992,30 @@ describe.each([
992992 client . index ( index . uid ) . search ( 'prince' , { } ) ,
993993 ) . rejects . toHaveProperty ( 'cause.code' , ErrorStatusCode . INDEX_NOT_FOUND ) ;
994994 } ) ;
995+
996+ test . only ( `${ permission } key: Search with locales` , async ( ) => {
997+ const ind = ( await getClient ( permission ) ) . index ( index . uid ) ,
998+ masterInd = ( await getClient ( 'Master' ) ) . index ( index . uid ) ;
999+
1000+ await masterInd . waitForTask (
1001+ (
1002+ await masterInd . updateSettings ( {
1003+ localizedAttributes : [
1004+ {
1005+ attributePatterns : [ 'title' , 'comment' ] ,
1006+ locales : [ 'fra' , 'eng' ] ,
1007+ } ,
1008+ ] ,
1009+ } )
1010+ ) . taskUid ,
1011+ ) ;
1012+
1013+ const response = await ind . search ( 'french' , {
1014+ locales : [ 'fra' , 'eng' ] ,
1015+ } ) ;
1016+
1017+ expect ( response . hits . length ) . toEqual ( 2 ) ;
1018+ } ) ;
9951019} ) ;
9961020
9971021describe . each ( [ { permission : 'No' } ] ) (
You can’t perform that action at this time.
0 commit comments