@@ -19,7 +19,7 @@ void snippetForAddApiKey() {
19
19
// Call the API
20
20
client .addApiKey (
21
21
new ApiKey ()
22
- .setAcl (List .of (Acl .fromValue ( "search" ) , Acl .fromValue ( "addObject" ) ))
22
+ .setAcl (List .of (Acl .SEARCH , Acl .ADD_OBJECT ))
23
23
.setDescription ("my new api key" )
24
24
.setValidity (300 )
25
25
.setMaxQueriesPerIPPerHour (100 )
@@ -81,8 +81,8 @@ void snippetForBatch() {
81
81
new BatchWriteParams ()
82
82
.setRequests (
83
83
List .of (
84
- new BatchRequest ().setAction (Action .fromValue ( "addObject" ) ).setBody (Map .of ("key" , "bar" , "foo" , "1" )),
85
- new BatchRequest ().setAction (Action .fromValue ( "addObject" ) ).setBody (Map .of ("key" , "baz" , "foo" , "2" ))
84
+ new BatchRequest ().setAction (Action .ADD_OBJECT ).setBody (Map .of ("key" , "bar" , "foo" , "1" )),
85
+ new BatchRequest ().setAction (Action .ADD_OBJECT ).setBody (Map .of ("key" , "baz" , "foo" , "2" ))
86
86
)
87
87
)
88
88
);
@@ -100,7 +100,7 @@ void snippetForBatch1() {
100
100
// Call the API
101
101
client .batch (
102
102
"<YOUR_INDEX_NAME>" ,
103
- new BatchWriteParams ().setRequests (List .of (new BatchRequest ().setAction (Action .fromValue ( "clear" ) ).setBody (Map .of ("key" , "value" ))))
103
+ new BatchWriteParams ().setRequests (List .of (new BatchRequest ().setAction (Action .CLEAR ).setBody (Map .of ("key" , "value" ))))
104
104
);
105
105
// SEPARATOR<
106
106
}
@@ -116,7 +116,7 @@ void snippetForBatch2() {
116
116
// Call the API
117
117
client .batch (
118
118
"<YOUR_INDEX_NAME>" ,
119
- new BatchWriteParams ().setRequests (List .of (new BatchRequest ().setAction (Action .fromValue ( "delete" ) ).setBody (Map .of ("key" , "value" ))))
119
+ new BatchWriteParams ().setRequests (List .of (new BatchRequest ().setAction (Action .DELETE ).setBody (Map .of ("key" , "value" ))))
120
120
);
121
121
// SEPARATOR<
122
122
}
@@ -132,8 +132,7 @@ void snippetForBatch3() {
132
132
// Call the API
133
133
client .batch (
134
134
"<YOUR_INDEX_NAME>" ,
135
- new BatchWriteParams ()
136
- .setRequests (List .of (new BatchRequest ().setAction (Action .fromValue ("deleteObject" )).setBody (Map .of ("key" , "value" ))))
135
+ new BatchWriteParams ().setRequests (List .of (new BatchRequest ().setAction (Action .DELETE_OBJECT ).setBody (Map .of ("key" , "value" ))))
137
136
);
138
137
// SEPARATOR<
139
138
}
@@ -150,7 +149,7 @@ void snippetForBatch4() {
150
149
client .batch (
151
150
"<YOUR_INDEX_NAME>" ,
152
151
new BatchWriteParams ()
153
- .setRequests (List .of (new BatchRequest ().setAction (Action .fromValue ( "partialUpdateObject" ) ).setBody (Map .of ("key" , "value" ))))
152
+ .setRequests (List .of (new BatchRequest ().setAction (Action .PARTIAL_UPDATE_OBJECT ).setBody (Map .of ("key" , "value" ))))
154
153
);
155
154
// SEPARATOR<
156
155
}
@@ -167,7 +166,7 @@ void snippetForBatch5() {
167
166
client .batch (
168
167
"<YOUR_INDEX_NAME>" ,
169
168
new BatchWriteParams ()
170
- .setRequests (List .of (new BatchRequest ().setAction (Action .fromValue ( "partialUpdateObjectNoCreate" ) ).setBody (Map .of ("key" , "value" ))))
169
+ .setRequests (List .of (new BatchRequest ().setAction (Action .PARTIAL_UPDATE_OBJECT_NO_CREATE ).setBody (Map .of ("key" , "value" ))))
171
170
);
172
171
// SEPARATOR<
173
172
}
@@ -183,8 +182,7 @@ void snippetForBatch6() {
183
182
// Call the API
184
183
client .batch (
185
184
"<YOUR_INDEX_NAME>" ,
186
- new BatchWriteParams ()
187
- .setRequests (List .of (new BatchRequest ().setAction (Action .fromValue ("updateObject" )).setBody (Map .of ("key" , "value" ))))
185
+ new BatchWriteParams ().setRequests (List .of (new BatchRequest ().setAction (Action .UPDATE_OBJECT ).setBody (Map .of ("key" , "value" ))))
188
186
);
189
187
// SEPARATOR<
190
188
}
@@ -212,21 +210,21 @@ void snippetForBatchDictionaryEntries() {
212
210
213
211
// Call the API
214
212
client .batchDictionaryEntries (
215
- DictionaryType .fromValue ( "plurals" ) ,
213
+ DictionaryType .PLURALS ,
216
214
new BatchDictionaryEntriesParams ()
217
215
.setClearExistingDictionaryEntries (true )
218
216
.setRequests (
219
217
List .of (
220
218
new BatchDictionaryEntriesRequest ()
221
- .setAction (DictionaryAction .fromValue ( "addEntry" ) )
219
+ .setAction (DictionaryAction .ADD_ENTRY )
222
220
.setBody (
223
221
new DictionaryEntry ()
224
222
.setObjectID ("1" )
225
- .setLanguage (SupportedLanguage .fromValue ( "en" ) )
223
+ .setLanguage (SupportedLanguage .EN )
226
224
.setWord ("fancy" )
227
225
.setWords (List .of ("believe" , "algolia" ))
228
226
.setDecomposition (List .of ("trust" , "algolia" ))
229
- .setState (DictionaryEntryState .fromValue ( "enabled" ) )
227
+ .setState (DictionaryEntryState .ENABLED )
230
228
)
231
229
)
232
230
)
@@ -244,21 +242,21 @@ void snippetForBatchDictionaryEntries1() {
244
242
245
243
// Call the API
246
244
client .batchDictionaryEntries (
247
- DictionaryType .fromValue ( "plurals" ) ,
245
+ DictionaryType .PLURALS ,
248
246
new BatchDictionaryEntriesParams ()
249
247
.setClearExistingDictionaryEntries (true )
250
248
.setRequests (
251
249
List .of (
252
250
new BatchDictionaryEntriesRequest ()
253
- .setAction (DictionaryAction .fromValue ( "deleteEntry" ) )
251
+ .setAction (DictionaryAction .DELETE_ENTRY )
254
252
.setBody (
255
253
new DictionaryEntry ()
256
254
.setObjectID ("1" )
257
- .setLanguage (SupportedLanguage .fromValue ( "en" ) )
255
+ .setLanguage (SupportedLanguage .EN )
258
256
.setWord ("fancy" )
259
257
.setWords (List .of ("believe" , "algolia" ))
260
258
.setDecomposition (List .of ("trust" , "algolia" ))
261
- .setState (DictionaryEntryState .fromValue ( "enabled" ) )
259
+ .setState (DictionaryEntryState .ENABLED )
262
260
)
263
261
)
264
262
)
@@ -276,17 +274,14 @@ void snippetForBatchDictionaryEntries2() {
276
274
277
275
// Call the API
278
276
client .batchDictionaryEntries (
279
- DictionaryType .fromValue ( "stopwords" ) ,
277
+ DictionaryType .STOPWORDS ,
280
278
new BatchDictionaryEntriesParams ()
281
279
.setRequests (
282
280
List .of (
283
281
new BatchDictionaryEntriesRequest ()
284
- .setAction (DictionaryAction .fromValue ( "addEntry" ) )
282
+ .setAction (DictionaryAction .ADD_ENTRY )
285
283
.setBody (
286
- new DictionaryEntry ()
287
- .setObjectID ("1" )
288
- .setLanguage (SupportedLanguage .fromValue ("en" ))
289
- .setAdditionalProperty ("additional" , "try me" )
284
+ new DictionaryEntry ().setObjectID ("1" ).setLanguage (SupportedLanguage .EN ).setAdditionalProperty ("additional" , "try me" )
290
285
)
291
286
)
292
287
)
@@ -756,9 +751,7 @@ void snippetForMultipleBatch() {
756
751
client .multipleBatch (
757
752
new BatchParams ()
758
753
.setRequests (
759
- List .of (
760
- new MultipleBatchRequest ().setAction (Action .fromValue ("addObject" )).setBody (Map .of ("key" , "value" )).setIndexName ("theIndexName" )
761
- )
754
+ List .of (new MultipleBatchRequest ().setAction (Action .ADD_OBJECT ).setBody (Map .of ("key" , "value" )).setIndexName ("theIndexName" ))
762
755
)
763
756
);
764
757
// SEPARATOR<
@@ -776,9 +769,9 @@ void snippetForOperationIndex() {
776
769
client .operationIndex (
777
770
"<SOURCE_INDEX_NAME>" ,
778
771
new OperationIndexParams ()
779
- .setOperation (OperationType .fromValue ( "move" ) )
772
+ .setOperation (OperationType .MOVE )
780
773
.setDestination ("<DESTINATION_INDEX_NAME>" )
781
- .setScope (List .of (ScopeType .fromValue ( "rules" ) , ScopeType .fromValue ( "settings" ) ))
774
+ .setScope (List .of (ScopeType .RULES , ScopeType .SETTINGS ))
782
775
);
783
776
// SEPARATOR<
784
777
}
@@ -794,7 +787,7 @@ void snippetForOperationIndex1() {
794
787
// Call the API
795
788
client .operationIndex (
796
789
"<SOURCE_INDEX_NAME>" ,
797
- new OperationIndexParams ().setOperation (OperationType .fromValue ( "copy" ) ).setDestination ("<DESTINATION_INDEX_NAME>" )
790
+ new OperationIndexParams ().setOperation (OperationType .COPY ).setDestination ("<DESTINATION_INDEX_NAME>" )
798
791
);
799
792
// SEPARATOR<
800
793
}
@@ -810,7 +803,7 @@ void snippetForOperationIndex2() {
810
803
// Call the API
811
804
client .operationIndex (
812
805
"<SOURCE_INDEX_NAME>" ,
813
- new OperationIndexParams ().setOperation (OperationType .fromValue ( "move" ) ).setDestination ("<DESTINATION_INDEX_NAME>" )
806
+ new OperationIndexParams ().setOperation (OperationType .MOVE ).setDestination ("<DESTINATION_INDEX_NAME>" )
814
807
);
815
808
// SEPARATOR<
816
809
}
@@ -831,7 +824,7 @@ void snippetForPartialUpdateObject() {
831
824
"id1" ,
832
825
AttributeToUpdate .of ("test" ),
833
826
"id2" ,
834
- new BuiltInOperation ().setOperation (BuiltInOperationType .fromValue ( "AddUnique" ) ).setValue ("test2" )
827
+ new BuiltInOperation ().setOperation (BuiltInOperationType .ADD_UNIQUE ).setValue ("test2" )
835
828
),
836
829
true
837
830
);
@@ -902,9 +895,7 @@ void snippetForSaveRule() {
902
895
client .saveRule (
903
896
"indexName" ,
904
897
"id1" ,
905
- new Rule ()
906
- .setObjectID ("id1" )
907
- .setConditions (List .of (new Condition ().setPattern ("apple" ).setAnchoring (Anchoring .fromValue ("contains" ))))
898
+ new Rule ().setObjectID ("id1" ).setConditions (List .of (new Condition ().setPattern ("apple" ).setAnchoring (Anchoring .CONTAINS )))
908
899
);
909
900
// SEPARATOR<
910
901
}
@@ -923,10 +914,10 @@ void snippetForSaveRules() {
923
914
List .of (
924
915
new Rule ()
925
916
.setObjectID ("a-rule-id" )
926
- .setConditions (List .of (new Condition ().setPattern ("smartphone" ).setAnchoring (Anchoring .fromValue ( "contains" ) ))),
917
+ .setConditions (List .of (new Condition ().setPattern ("smartphone" ).setAnchoring (Anchoring .CONTAINS ))),
927
918
new Rule ()
928
919
.setObjectID ("a-second-rule-id" )
929
- .setConditions (List .of (new Condition ().setPattern ("apple" ).setAnchoring (Anchoring .fromValue ( "contains" ) )))
920
+ .setConditions (List .of (new Condition ().setPattern ("apple" ).setAnchoring (Anchoring .CONTAINS )))
930
921
),
931
922
false ,
932
923
true
@@ -946,7 +937,7 @@ void snippetForSaveSynonym() {
946
937
client .saveSynonym (
947
938
"indexName" ,
948
939
"id1" ,
949
- new SynonymHit ().setObjectID ("id1" ).setType (SynonymType .fromValue ( "synonym" ) ).setSynonyms (List .of ("car" , "vehicule" , "auto" )),
940
+ new SynonymHit ().setObjectID ("id1" ).setType (SynonymType .SYNONYM ).setSynonyms (List .of ("car" , "vehicule" , "auto" )),
950
941
true
951
942
);
952
943
// SEPARATOR<
@@ -964,10 +955,10 @@ void snippetForSaveSynonyms() {
964
955
client .saveSynonyms (
965
956
"<YOUR_INDEX_NAME>" ,
966
957
List .of (
967
- new SynonymHit ().setObjectID ("id1" ).setType (SynonymType .fromValue ( "synonym" ) ).setSynonyms (List .of ("car" , "vehicule" , "auto" )),
958
+ new SynonymHit ().setObjectID ("id1" ).setType (SynonymType .SYNONYM ).setSynonyms (List .of ("car" , "vehicule" , "auto" )),
968
959
new SynonymHit ()
969
960
.setObjectID ("id2" )
970
- .setType (SynonymType .fromValue ( "onewaysynonym" ) )
961
+ .setType (SynonymType .ONEWAYSYNONYM )
971
962
.setInput ("iphone" )
972
963
.setSynonyms (List .of ("ephone" , "aphone" , "yphone" ))
973
964
),
@@ -1101,7 +1092,7 @@ void snippetForSearchDictionaryEntries() {
1101
1092
SearchClient client = new SearchClient ("YOUR_APP_ID" , "YOUR_API_KEY" );
1102
1093
1103
1094
// Call the API
1104
- client .searchDictionaryEntries (DictionaryType .fromValue ( "stopwords" ) , new SearchDictionaryEntriesParams ().setQuery ("about" ));
1095
+ client .searchDictionaryEntries (DictionaryType .STOPWORDS , new SearchDictionaryEntriesParams ().setQuery ("about" ));
1105
1096
// SEPARATOR<
1106
1097
}
1107
1098
@@ -1213,11 +1204,7 @@ void snippetForUpdateApiKey() {
1213
1204
// Call the API
1214
1205
client .updateApiKey (
1215
1206
"myApiKey" ,
1216
- new ApiKey ()
1217
- .setAcl (List .of (Acl .fromValue ("search" ), Acl .fromValue ("addObject" )))
1218
- .setValidity (300 )
1219
- .setMaxQueriesPerIPPerHour (100 )
1220
- .setMaxHitsPerQuery (20 )
1207
+ new ApiKey ().setAcl (List .of (Acl .SEARCH , Acl .ADD_OBJECT )).setValidity (300 ).setMaxQueriesPerIPPerHour (100 ).setMaxHitsPerQuery (20 )
1221
1208
);
1222
1209
// SEPARATOR<
1223
1210
}
0 commit comments