From 63fbf807a9d05670707d672962d71550faac0a11 Mon Sep 17 00:00:00 2001 From: Kishore Nallan Date: Wed, 24 Aug 2022 12:45:34 +0530 Subject: [PATCH] Enable num_typos for th locale. --- src/index.cpp | 2 +- test/collection_locale_test.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/index.cpp b/src/index.cpp index 59ce0078..73b29923 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -2902,7 +2902,7 @@ void Index::fuzzy_search_fields(const std::vector& the_fields, int64_t field_num_typos = (field_id < num_typos.size()) ? num_typos[the_field.orig_index] : num_typos[0]; auto& locale = search_schema.at(the_field.name).locale; - if(locale != "" && locale != "en" && !Tokenizer::is_cyrillic(locale)) { + if(locale != "" && locale != "en" && locale != "th" && !Tokenizer::is_cyrillic(locale)) { // disable fuzzy trie traversal for non-english locales field_num_typos = 0; } diff --git a/test/collection_locale_test.cpp b/test/collection_locale_test.cpp index 6095a97d..ab40b163 100644 --- a/test/collection_locale_test.cpp +++ b/test/collection_locale_test.cpp @@ -278,6 +278,7 @@ TEST_F(CollectionLocaleTest, SearchThaiTextPreSegmentedQuery) { {"ความเหลื่อมล้ำ", "Compound Word"}, // ความ, เหลื่อม, ล้ำ {"การกระจายรายได้", "Doc A"}, {"จารีย์", "Doc B"}, + {"Meiji", "Doc C"}, }; for(size_t i=0; i()); ASSERT_EQ("0", results["hits"][0]["document"]["id"].get()); + + results = coll1->search("meji", + {"title"}, "", {}, {}, {2}, 10, 1, FREQUENCY, {true}, + 10, spp::sparse_hash_set(), + spp::sparse_hash_set(), 10, "", 30, 4, "", 40, {}, {}, {}, 0, + "", "", {1}, 1000, true, true).get(); + + ASSERT_EQ(1, results["found"].get()); + ASSERT_EQ("3", results["hits"][0]["document"]["id"].get()); + + results = coll1->search("ควม", + {"title"}, "", {}, {}, {2}, 10, 1, FREQUENCY, {true}, + 10, spp::sparse_hash_set(), + spp::sparse_hash_set(), 10, "", 30, 4, "", 40, {}, {}, {}, 0, + "", "", {1}, 1000, true, true).get(); + + ASSERT_EQ(1, results["found"].get()); + ASSERT_EQ("0", results["hits"][0]["document"]["id"].get()); } TEST_F(CollectionLocaleTest, SearchAgainstThaiTextExactMatch) {