@@ -259,6 +259,7 @@ func TestIndex_GetSettings(t *testing.T) {
259
259
SeparatorTokens : make ([]string , 0 ),
260
260
NonSeparatorTokens : make ([]string , 0 ),
261
261
Dictionary : make ([]string , 0 ),
262
+ LocalizedAttributes : nil ,
262
263
},
263
264
},
264
265
{
@@ -284,6 +285,7 @@ func TestIndex_GetSettings(t *testing.T) {
284
285
SeparatorTokens : make ([]string , 0 ),
285
286
NonSeparatorTokens : make ([]string , 0 ),
286
287
Dictionary : make ([]string , 0 ),
288
+ LocalizedAttributes : nil ,
287
289
},
288
290
},
289
291
}
@@ -893,6 +895,7 @@ func TestIndex_ResetSettings(t *testing.T) {
893
895
SeparatorTokens : make ([]string , 0 ),
894
896
NonSeparatorTokens : make ([]string , 0 ),
895
897
Dictionary : make ([]string , 0 ),
898
+ LocalizedAttributes : nil ,
896
899
},
897
900
},
898
901
{
@@ -920,6 +923,7 @@ func TestIndex_ResetSettings(t *testing.T) {
920
923
SeparatorTokens : make ([]string , 0 ),
921
924
NonSeparatorTokens : make ([]string , 0 ),
922
925
Dictionary : make ([]string , 0 ),
926
+ LocalizedAttributes : nil ,
923
927
},
924
928
},
925
929
}
@@ -1698,6 +1702,12 @@ func TestIndex_UpdateSettings(t *testing.T) {
1698
1702
SeparatorTokens : make ([]string , 0 ),
1699
1703
NonSeparatorTokens : make ([]string , 0 ),
1700
1704
Dictionary : make ([]string , 0 ),
1705
+ LocalizedAttributes : []* LocalizedAttributes {
1706
+ {
1707
+ Locales : []Locate {JPN , ENG },
1708
+ AttributePatterns : []string {"*_ja" },
1709
+ },
1710
+ },
1701
1711
},
1702
1712
},
1703
1713
wantTask : & TaskInfo {
@@ -1720,6 +1730,12 @@ func TestIndex_UpdateSettings(t *testing.T) {
1720
1730
SeparatorTokens : make ([]string , 0 ),
1721
1731
NonSeparatorTokens : make ([]string , 0 ),
1722
1732
Dictionary : make ([]string , 0 ),
1733
+ LocalizedAttributes : []* LocalizedAttributes {
1734
+ {
1735
+ Locales : []Locate {JPN , ENG },
1736
+ AttributePatterns : []string {"*_ja" },
1737
+ },
1738
+ },
1723
1739
},
1724
1740
},
1725
1741
{
@@ -3687,3 +3703,56 @@ func Test_ProximityPrecision(t *testing.T) {
3687
3703
require .NoError (t , err )
3688
3704
require .Equal (t , ByWord , got )
3689
3705
}
3706
+
3707
+ func Test_LocalizedAttributes (t * testing.T ) {
3708
+ c := setup (t , "" )
3709
+ t .Cleanup (cleanup (c ))
3710
+
3711
+ indexID := "newIndexUID"
3712
+ i := c .Index (indexID )
3713
+ taskInfo , err := c .CreateIndex (& IndexConfig {Uid : indexID })
3714
+ require .NoError (t , err )
3715
+ testWaitForTask (t , i , taskInfo )
3716
+
3717
+ defer t .Cleanup (cleanup (c ))
3718
+
3719
+ t .Run ("Test valid locate" , func (t * testing.T ) {
3720
+ got , err := i .GetLocalizedAttributes ()
3721
+ require .NoError (t , err )
3722
+ require .Len (t , got , 0 )
3723
+
3724
+ localized := & LocalizedAttributes {
3725
+ Locales : []Locate {JPN , ENG },
3726
+ AttributePatterns : []string {"*_ja" },
3727
+ }
3728
+
3729
+ task , err := i .UpdateLocalizedAttributes ([]* LocalizedAttributes {localized })
3730
+ require .NoError (t , err )
3731
+ testWaitForTask (t , i , task )
3732
+
3733
+ got , err = i .GetLocalizedAttributes ()
3734
+ require .NoError (t , err )
3735
+ require .NotNil (t , got )
3736
+
3737
+ require .Equal (t , localized .Locales , got [0 ].Locales )
3738
+ require .Equal (t , localized .AttributePatterns , got [0 ].AttributePatterns )
3739
+
3740
+ task , err = i .ResetLocalizedAttributes ()
3741
+ require .NoError (t , err )
3742
+ testWaitForTask (t , i , task )
3743
+
3744
+ got , err = i .GetLocalizedAttributes ()
3745
+ require .NoError (t , err )
3746
+ require .Len (t , got , 0 )
3747
+ })
3748
+
3749
+ t .Run ("Test invalid locate" , func (t * testing.T ) {
3750
+ invalidLocalized := & LocalizedAttributes {
3751
+ Locales : []Locate {"foo" },
3752
+ AttributePatterns : []string {"*_ja" },
3753
+ }
3754
+
3755
+ _ , err := i .UpdateLocalizedAttributes ([]* LocalizedAttributes {invalidLocalized })
3756
+ require .Error (t , err )
3757
+ })
3758
+ }
0 commit comments