Skip to content

Commit af89442

Browse files
committed
Update code sample for the typo tolerance
1 parent 3b089de commit af89442

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,22 @@ update_displayed_attributes_1: |-
192192
});
193193
reset_displayed_attributes_1: |-
194194
client.index("movies").resetDisplayedAttributesSettings();
195+
get_typo_tolerance_1:
196+
client.index("books").getTypoToleranceSettings();
197+
update_typo_tolerance_1: |-
198+
TypoTolerance typoTolerance = new TypoTolerance();
199+
typoTolerance.setDisableOnAttributes(new String[] {"title"});
200+
HashMap<String, Integer> minWordSizeTypos =
201+
new HashMap<String, Integer>() {
202+
{
203+
put("oneTypo", 4);
204+
put("twoTypos", 10);
205+
}
206+
};
207+
typoTolerance.setMinWordSizeForTypos(minWordSizeTypos);
208+
client.index("movies").updateTypoToleranceSettings(typoTolerance);
209+
reset_typo_tolerance_1: |-
210+
client.index("books").resetTypoToleranceSettings();
195211
get_index_stats_1: |-
196212
client.index("movies").getStats();
197213
get_indexes_stats_1: |-
@@ -321,6 +337,40 @@ settings_guide_sortable_1: |-
321337
"author",
322338
});
323339
client.index("books").updateSettings(settings);
340+
settings_guide_typo_tolerance_1: |-
341+
TypoTolerance typoTolerance = new TypoTolerance();
342+
typoTolerance.setDisableOnAttributes(new String[] {"title"});
343+
HashMap<String, Integer> minWordSizeTypos =
344+
new HashMap<String, Integer>() {
345+
{
346+
put("twoTypos", 12);
347+
}
348+
};
349+
typoTolerance.setMinWordSizeForTypos(minWordSizeTypos);
350+
client.index("movies").updateTypoToleranceSettings(typoTolerance);
351+
typo_tolerance_guide_1: |-
352+
TypoTolerance typoTolerance = new TypoTolerance();
353+
typoTolerance.setEnabled(false);
354+
client.index("movies").updateTypoToleranceSettings(typoTolerance);
355+
typo_tolerance_guide_2: |-
356+
TypoTolerance typoTolerance = new TypoTolerance();
357+
typoTolerance.setDisableOnAttributes(new String[] {"title"});
358+
client.index("movies").updateTypoToleranceSettings(typoTolerance);
359+
typo_tolerance_guide_3: |-
360+
TypoTolerance typoTolerance = new TypoTolerance();
361+
typoTolerance.setDisableOnWords(new String[] {"shrek"});
362+
client.index("movies").updateTypoToleranceSettings(typoTolerance);
363+
typo_tolerance_guide_4: |-
364+
TypoTolerance typoTolerance = new TypoTolerance();
365+
HashMap<String, Integer> minWordSizeTypos =
366+
new HashMap<String, Integer>() {
367+
{
368+
put("oneTypo", 4);
369+
put("twoTypos", 10);
370+
}
371+
};
372+
typoTolerance.setMinWordSizeForTypos(minWordSizeTypos);
373+
client.index("movies").updateTypoToleranceSettings(typoTolerance);
324374
documents_guide_add_movie_1: |-
325375
client.index("movies").addDocuments("[{"
326376
+ "\"movie_id\": 123sq178,"

0 commit comments

Comments
 (0)