From 9076458ecbae891ff47a7848be47b3ee37a25cd4 Mon Sep 17 00:00:00 2001 From: alallema Date: Thu, 5 May 2022 14:01:17 +0200 Subject: [PATCH] Add typo tolerance sample --- .code-samples.meilisearch.yaml | 54 ++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index d95a8e7ac..15fa474b7 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -192,6 +192,22 @@ update_displayed_attributes_1: |- }); reset_displayed_attributes_1: |- client.index("movies").resetDisplayedAttributesSettings(); +get_typo_tolerance_1: + client.index("books").getTypoToleranceSettings(); +update_typo_tolerance_1: |- + TypoTolerance typoTolerance = new TypoTolerance(); + typoTolerance.setDisableOnAttributes(new String[] {"title"}); + HashMap minWordSizeTypos = + new HashMap() { + { + put("oneTypo", 4); + put("twoTypos", 10); + } + }; + typoTolerance.setMinWordSizeForTypos(minWordSizeTypos); + client.index("movies").updateTypoToleranceSettings(typoTolerance); +reset_typo_tolerance_1: |- + client.index("books").resetTypoToleranceSettings(); get_index_stats_1: |- client.index("movies").getStats(); get_indexes_stats_1: |- @@ -261,11 +277,11 @@ search_parameter_guide_crop_marker_1: |- client.index("movies").search(searchRequest); search_parameter_guide_highlight_1: |- SearchRequest searchRequest = - new SearchRequest("and").setAttributesToHighlight(new String[] {"overview"}); + new SearchRequest("winter feast").setAttributesToHighlight(new String[] {"overview"}); client.index("movies").search(searchRequest); search_parameter_guide_highlight_tag_1: |- SearchRequest searchRequest = - new SearchRequest("and") + new SearchRequest("winter feast") .setAttributesToHighlight(new String[] {"overview"}) .setHighlightPreTag("") .setHighlightPostTag(""); @@ -334,6 +350,40 @@ settings_guide_sortable_1: |- "author", }); client.index("books").updateSettings(settings); +settings_guide_typo_tolerance_1: |- + TypoTolerance typoTolerance = new TypoTolerance(); + typoTolerance.setDisableOnAttributes(new String[] {"title"}); + HashMap minWordSizeTypos = + new HashMap() { + { + put("twoTypos", 12); + } + }; + typoTolerance.setMinWordSizeForTypos(minWordSizeTypos); + client.index("movies").updateTypoToleranceSettings(typoTolerance); +typo_tolerance_guide_1: |- + TypoTolerance typoTolerance = new TypoTolerance(); + typoTolerance.setEnabled(false); + client.index("movies").updateTypoToleranceSettings(typoTolerance); +typo_tolerance_guide_2: |- + TypoTolerance typoTolerance = new TypoTolerance(); + typoTolerance.setDisableOnAttributes(new String[] {"title"}); + client.index("movies").updateTypoToleranceSettings(typoTolerance); +typo_tolerance_guide_3: |- + TypoTolerance typoTolerance = new TypoTolerance(); + typoTolerance.setDisableOnWords(new String[] {"shrek"}); + client.index("movies").updateTypoToleranceSettings(typoTolerance); +typo_tolerance_guide_4: |- + TypoTolerance typoTolerance = new TypoTolerance(); + HashMap minWordSizeTypos = + new HashMap() { + { + put("oneTypo", 4); + put("twoTypos", 10); + } + }; + typoTolerance.setMinWordSizeForTypos(minWordSizeTypos); + client.index("movies").updateTypoToleranceSettings(typoTolerance); documents_guide_add_movie_1: |- client.index("movies").addDocuments("[{" + "\"movie_id\": 123sq178,"