diff --git a/test/clt-tests/core/call-autocomplete-force-bigrams.rec b/test/clt-tests/core/call-autocomplete-force-bigrams.rec new file mode 100644 index 0000000000..9f95c607e8 --- /dev/null +++ b/test/clt-tests/core/call-autocomplete-force-bigrams.rec @@ -0,0 +1,189 @@ +––– comment ––– +Test for force_bigrams option in CALL AUTOCOMPLETE, CALL SUGGEST, and fuzzy search +Issue: https://github.com/manticoresoftware/manticoresearch/issues/3853 + +This test verifies that force_bigrams parameter works correctly in three contexts: +1. CALL AUTOCOMPLETE (tests 1-9): autocomplete with bigram-based fuzzy matching +2. CALL SUGGEST (tests 10-15): suggestions with bigram-based fuzzy matching +3. SELECT with OPTION fuzzy=1 (tests 16-21): regular search with fuzzy option +––– block: ../base/start-searchd-with-buddy ––– +––– input ––– +mysql -P9306 -h0 -e "drop table if exists t" +––– output ––– +––– input ––– +mysql -P9306 -h0 -e "create table t(f text) min_infix_len='2'" +––– output ––– +––– input ––– +mysql -P9306 -h0 -e "insert into t values(1,'iphone george planet letter')" +––– output ––– +––– comment ––– +Test 1: force_bigrams=1 finds transposition errors +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('ipohne', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: iphone +––– comment ––– +Test 2: force_bigrams=0 does NOT find transpositions in long words +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('ipohne', 't', 0 as force_bigrams)\G" +––– output ––– +––– comment ––– +Test 3: Transposition with force_bigrams=1 +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('geroge', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: george +––– comment ––– +Test 4: Same word with force_bigrams=0 - does NOT find transposition +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('geroge', 't', 0 as force_bigrams)\G" +––– output ––– +––– comment ––– +Test 5: 6-char word "planet" (boundary case), force_bigrams=0, expect: found +Note: "lanet" uses bigrams, "planet" uses trigrams, but fuzzy matching still works (edit distance=1) +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('lanet', 't', 0 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: planet +––– comment ––– +Test 6: Same word with force_bigrams=1, expect: found (same result as Test 5) +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('lanet', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: planet +––– comment ––– +Test 7: Append option with force_bigrams +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('geor', 't', 1 as append, 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: george +––– comment ––– +Test 8: Prepend option with force_bigrams +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('eorge', 't', 1 as prepend, 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: george +––– comment ––– +Test 9: Multiple options with force_bigrams +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('geor', 't', 1 as fuzziness, 1 as append, 1 as prepend, 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: george +––– comment ––– +Test 10: CALL SUGGEST with force_bigrams=1, transposition in 6-char word +––– input ––– +mysql -P9306 -h0 -e "call suggest('ipohne', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** + suggest: iphone +distance: 2 + docs: 1 +*************************** 2. row *************************** + suggest: planet +distance: 4 + docs: 1 +––– comment ––– +Test 11: CALL SUGGEST with force_bigrams=0, same word, expect: NOT found +––– input ––– +mysql -P9306 -h0 -e "call suggest('ipohne', 't', 0 as force_bigrams)\G" +––– output ––– +––– comment ––– +Test 12: CALL SUGGEST with force_bigrams=1, transposition in "george" +––– input ––– +mysql -P9306 -h0 -e "call suggest('geroge', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** + suggest: george +distance: 2 + docs: 1 +––– comment ––– +Test 13: CALL SUGGEST with force_bigrams=0, same word, expect: NOT found +––– input ––– +mysql -P9306 -h0 -e "call suggest('geroge', 't', 0 as force_bigrams)\G" +––– output ––– +––– comment ––– +Test 14: CALL SUGGEST with force_bigrams=0, "planet" boundary case, expect: found +––– input ––– +mysql -P9306 -h0 -e "call suggest('lanet', 't', 0 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** + suggest: planet +distance: 1 + docs: 1 +*************************** 2. row *************************** + suggest: letter +distance: 4 + docs: 1 +––– comment ––– +Test 15: CALL SUGGEST with force_bigrams=1, same word, expect: found (same result) +––– input ––– +mysql -P9306 -h0 -e "call suggest('lanet', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** + suggest: planet +distance: 1 + docs: 1 +*************************** 2. row *************************** + suggest: letter +distance: 4 + docs: 1 +––– comment ––– +Test 16: SELECT with force_bigrams=1, transposition in 6-char word +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force_bigrams=1" +––– output ––– ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ +––– comment ––– +Test 17: SELECT with force_bigrams=0, same word, expect: NOT found +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force_bigrams=0" +––– output ––– +––– comment ––– +Test 18: SELECT with force_bigrams=1, transposition in "george" +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force_bigrams=1" +––– output ––– ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ +––– comment ––– +Test 19: SELECT with force_bigrams=0, same word, expect: NOT found +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force_bigrams=0" +––– output ––– +––– comment ––– +Test 20: SELECT with force_bigrams=0, "planet" boundary case, expect: found +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('lanet') OPTION fuzzy=1, force_bigrams=0" +––– output ––– ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ +––– comment ––– +Test 21: SELECT with force_bigrams=1, same word, expect: found (same result) +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('lanet') OPTION fuzzy=1, force_bigrams=1" +––– output ––– ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ +––– input ––– +mysql -P9306 -h0 -e "drop table t" +––– output –––