Skip to content

Commit 93147dc

Browse files
authored
guides: snippets saveObjects/listIndices (#4380)
1 parent a273b76 commit 93147dc

File tree

5 files changed

+259
-1
lines changed

5 files changed

+259
-1
lines changed

generators/src/main/java/com/algolia/codegen/cts/tests/ParametersWithDataType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ private String inferDataType(Object param, CodegenParameter spec, Map<String, Ob
592592
spec.setIsArray(true);
593593
// This is just to find the correct path in `handlePrimitive`, but it's not always the
594594
// real type
595+
// FIXME: this set voluntarily the type to string, which will fail
596+
// We need to infer the real type
595597
CodegenProperty baseItems = new CodegenProperty();
596598
baseItems.dataType = "String";
597599
spec.setItems(baseItems);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isRoot}}{{#lambda.camelcase}}{{key}}{{/lambda.camelcase}}: {{/isRoot}}{{^isRoot}}{{#useAnonymousKey}}{{#isParentFreeFormObject}}"{{/isParentFreeFormObject}}{{#isAdditionalProperty}}"{{/isAdditionalProperty}}{{#lambda.camelcase}}{{key}}{{/lambda.camelcase}}{{#isParentFreeFormObject}}"{{/isParentFreeFormObject}}{{#isAdditionalProperty}}"{{/isAdditionalProperty}}: {{/useAnonymousKey}}{{/isRoot}}
1+
{{#isRoot}}{{#lambda.camelcase}}{{key}}{{/lambda.camelcase}}: {{/isRoot}}{{^isRoot}}{{#useAnonymousKey}}{{#isParentFreeFormObject}}"{{/isParentFreeFormObject}}{{#isAdditionalProperty}}"{{/isAdditionalProperty}}{{#isParentFreeFormObject}}{{key}}{{/isParentFreeFormObject}}{{^isParentFreeFormObject}}{{#lambda.camelcase}}{{key}}{{/lambda.camelcase}}{{/isParentFreeFormObject}}{{#isParentFreeFormObject}}"{{/isParentFreeFormObject}}{{#isAdditionalProperty}}"{{/isAdditionalProperty}}: {{/useAnonymousKey}}{{/isRoot}}

tests/CTS/client/search/saveObjects.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,60 @@
9393
}
9494
}
9595
]
96+
},
97+
{
98+
"testName": "saveObjectsPlaylist",
99+
"autoCreateClient": false,
100+
"steps": [
101+
{
102+
"type": "method",
103+
"method": "saveObjects",
104+
"parameters": {
105+
"indexName": "playlists",
106+
"objects": [
107+
{
108+
"objectID": "1",
109+
"user": "public",
110+
"name": "Hot 100 Billboard Charts",
111+
"tracks": [
112+
"Despacito",
113+
"Shape of You"
114+
],
115+
"createdAt": 1500240452
116+
}
117+
]
118+
}
119+
}
120+
]
121+
},
122+
{
123+
"testName": "saveObjectsPublicUser",
124+
"autoCreateClient": false,
125+
"steps": [
126+
{
127+
"type": "method",
128+
"method": "saveObjects",
129+
"parameters": {
130+
"indexName": "playlists",
131+
"objects": [
132+
{
133+
"objectID": "1",
134+
"user": "public",
135+
"name": "Hot 100 Billboard Charts",
136+
"tracks": [
137+
"Despacito",
138+
"Shape of You"
139+
],
140+
"createdAt": 1500240452
141+
}
142+
],
143+
"requestOptions": {
144+
"headers": {
145+
"X-Algolia-User-ID": "*"
146+
}
147+
}
148+
}
149+
}
150+
]
96151
}
97152
]

tests/CTS/requests/search/listIndices.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[
22
{
33
"testName": "listIndices with minimal parameters",
4+
"isSnippet": true,
45
"parameters": {},
56
"request": {
67
"path": "/1/indexes",

tests/CTS/requests/search/setSettings.json

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,5 +1327,205 @@
13271327
}
13281328
}
13291329
}
1330+
},
1331+
{
1332+
"testName": "searchableAttributesWithCustomRankingsAndAttributesForFaceting",
1333+
"isSnippet": true,
1334+
"parameters": {
1335+
"indexName": "theIndexName",
1336+
"indexSettings": {
1337+
"searchableAttributes": [
1338+
"brand",
1339+
"name",
1340+
"categories",
1341+
"unordered(description)"
1342+
],
1343+
"customRanking": [
1344+
"desc(popularity)"
1345+
],
1346+
"attributesForFaceting": [
1347+
"searchable(brand)",
1348+
"type",
1349+
"categories",
1350+
"price"
1351+
]
1352+
}
1353+
},
1354+
"request": {
1355+
"path": "/1/indexes/theIndexName/settings",
1356+
"method": "PUT",
1357+
"body": {
1358+
"searchableAttributes": [
1359+
"brand",
1360+
"name",
1361+
"categories",
1362+
"unordered(description)"
1363+
],
1364+
"customRanking": [
1365+
"desc(popularity)"
1366+
],
1367+
"attributesForFaceting": [
1368+
"searchable(brand)",
1369+
"type",
1370+
"categories",
1371+
"price"
1372+
]
1373+
}
1374+
}
1375+
},
1376+
{
1377+
"testName": "searchableAttributesProductReferenceSuffixes",
1378+
"isSnippet": true,
1379+
"parameters": {
1380+
"indexName": "theIndexName",
1381+
"indexSettings": {
1382+
"searchableAttributes": [
1383+
"name",
1384+
"product_reference",
1385+
"product_reference_suffixes"
1386+
]
1387+
}
1388+
},
1389+
"request": {
1390+
"path": "/1/indexes/theIndexName/settings",
1391+
"method": "PUT",
1392+
"body": {
1393+
"searchableAttributes": [
1394+
"name",
1395+
"product_reference",
1396+
"product_reference_suffixes"
1397+
]
1398+
}
1399+
}
1400+
},
1401+
{
1402+
"testName": "queryLanguageAndIgnorePlurals",
1403+
"isSnippet": true,
1404+
"parameters": {
1405+
"indexName": "theIndexName",
1406+
"indexSettings": {
1407+
"queryLanguages": [
1408+
"en"
1409+
],
1410+
"ignorePlurals": true
1411+
}
1412+
},
1413+
"request": {
1414+
"path": "/1/indexes/theIndexName/settings",
1415+
"method": "PUT",
1416+
"body": {
1417+
"queryLanguages": [
1418+
"en"
1419+
],
1420+
"ignorePlurals": true
1421+
}
1422+
}
1423+
},
1424+
{
1425+
"testName": "searchableAttributesInMovies",
1426+
"isSnippet": true,
1427+
"parameters": {
1428+
"indexName": "movies",
1429+
"indexSettings": {
1430+
"searchableAttributes": [
1431+
"title_eng", "title_fr", "title_es"
1432+
]
1433+
}
1434+
},
1435+
"request": {
1436+
"path": "/1/indexes/movies/settings",
1437+
"method": "PUT",
1438+
"body": {
1439+
"searchableAttributes": [
1440+
"title_eng", "title_fr", "title_es"
1441+
]
1442+
}
1443+
}
1444+
},
1445+
{
1446+
"testName": "disablePrefixOnAttributes",
1447+
"isSnippet": true,
1448+
"parameters": {
1449+
"indexName": "theIndexName",
1450+
"indexSettings": {
1451+
"disablePrefixOnAttributes": [
1452+
"serial_number"
1453+
]
1454+
}
1455+
},
1456+
"request": {
1457+
"path": "/1/indexes/theIndexName/settings",
1458+
"method": "PUT",
1459+
"body": {
1460+
"disablePrefixOnAttributes": [
1461+
"serial_number"
1462+
]
1463+
}
1464+
}
1465+
},
1466+
{
1467+
"testName": "disableTypoToleranceOnAttributes",
1468+
"isSnippet": true,
1469+
"parameters": {
1470+
"indexName": "theIndexName",
1471+
"indexSettings": {
1472+
"disableTypoToleranceOnAttributes": [
1473+
"serial_number"
1474+
]
1475+
}
1476+
},
1477+
"request": {
1478+
"path": "/1/indexes/theIndexName/settings",
1479+
"method": "PUT",
1480+
"body": {
1481+
"disableTypoToleranceOnAttributes": [
1482+
"serial_number"
1483+
]
1484+
}
1485+
}
1486+
},
1487+
{
1488+
"testName": "searchableAttributesSimpleExample",
1489+
"isSnippet": true,
1490+
"parameters": {
1491+
"indexName": "theIndexName",
1492+
"indexSettings": {
1493+
"searchableAttributes": [
1494+
"serial_number"
1495+
]
1496+
}
1497+
},
1498+
"request": {
1499+
"path": "/1/indexes/theIndexName/settings",
1500+
"method": "PUT",
1501+
"body": {
1502+
"searchableAttributes": [
1503+
"serial_number"
1504+
]
1505+
}
1506+
}
1507+
},
1508+
{
1509+
"testName": "searchableAttributesSimpleExampleAlt",
1510+
"isSnippet": true,
1511+
"parameters": {
1512+
"indexName": "theIndexName",
1513+
"indexSettings": {
1514+
"searchableAttributes": [
1515+
"serial_number",
1516+
"serial_number_suffixes"
1517+
]
1518+
}
1519+
},
1520+
"request": {
1521+
"path": "/1/indexes/theIndexName/settings",
1522+
"method": "PUT",
1523+
"body": {
1524+
"searchableAttributes": [
1525+
"serial_number",
1526+
"serial_number_suffixes"
1527+
]
1528+
}
1529+
}
13301530
}
13311531
]

0 commit comments

Comments
 (0)