From 14fa29249493d3457446726006a5e79d5685e6a7 Mon Sep 17 00:00:00 2001 From: Pavel_Shilin Date: Sun, 9 Nov 2025 20:04:01 +0100 Subject: [PATCH 1/4] Add comprehensive tests for force_bigrams in CALL SUGGEST, fuzzy search, and CALL AUTOCOMPLETE (issue #3853) --- ...ll-autocomplete-force-bigrams-vertical.rec | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec diff --git a/test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec b/test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec new file mode 100644 index 0000000000..8eb1ccbb57 --- /dev/null +++ b/test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec @@ -0,0 +1,179 @@ +––– 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-14): suggestions with bigram-based fuzzy matching +3. SELECT with OPTION fuzzy=1 (tests 15-19): regular search with fuzzy option + +The force_bigrams option helps find transposition errors (e.g., "ipohne" -> "iphone") +in longer words where bigrams are not used by default. +––– 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 developer george something 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: Long word transposition + force_bigrams +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('develepor', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: developer +––– comment ––– +Test 4: Transposition in middle +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('geroge', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: george +––– comment ––– +Test 5: Another transposition +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('somtehing', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: something +––– comment ––– +Test 6: Short word - bigrams automatic +––– input ––– +mysql -P9306 -h0 -e "call autocomplete('lanet', 't', 0 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** +query: planet +––– comment ––– +Test 7: Append option +––– 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 +––– 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 +––– 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 - finds transpositions (SUGGEST is fuzzy by default) +––– 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 - may not find transpositions in long words +––– input ––– +mysql -P9306 -h0 -e "call suggest('ipohne', 't', 0 as force_bigrams)\G" +––– output ––– +––– comment ––– +Test 12: CALL SUGGEST with force_bigrams=1 - long word transposition +––– input ––– +mysql -P9306 -h0 -e "call suggest('develepor', 't', 1 as force_bigrams)\G" +––– output ––– +*************************** 1. row *************************** + suggest: developer +distance: 2 + docs: 1 +––– comment ––– +Test 13: CALL SUGGEST with force_bigrams=1 - another transposition +––– 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 14: CALL SUGGEST with force_bigrams=0 - short word (bigrams automatic) +––– 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: SELECT with OPTION fuzzy=1, force_bigrams=1 - finds transposition errors +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force_bigrams=1" +––– output ––– ++------+-------------------------------------------------+ +| id | f | ++------+-------------------------------------------------+ +| 1 | iphone developer george something planet letter | ++------+-------------------------------------------------+ +––– comment ––– +Test 16: SELECT with OPTION fuzzy=1, force_bigrams=0 - may not find transpositions in long words +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force_bigrams=0" +––– output ––– +––– comment ––– +Test 17: SELECT with OPTION fuzzy=1, force_bigrams=1 - long word transposition +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('develepor') OPTION fuzzy=1, force_bigrams=1" +––– output ––– ++------+-------------------------------------------------+ +| id | f | ++------+-------------------------------------------------+ +| 1 | iphone developer george something planet letter | ++------+-------------------------------------------------+ +––– comment ––– +Test 18: SELECT with OPTION fuzzy=1, force_bigrams=1 - another transposition +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force_bigrams=1" +––– output ––– ++------+-------------------------------------------------+ +| id | f | ++------+-------------------------------------------------+ +| 1 | iphone developer george something planet letter | ++------+-------------------------------------------------+ +––– comment ––– +Test 19: SELECT with OPTION fuzzy=1, force_bigrams=0 - short word (bigrams automatic) +––– input ––– +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('lanet') OPTION fuzzy=1, force_bigrams=0" +––– output ––– ++------+-------------------------------------------------+ +| id | f | ++------+-------------------------------------------------+ +| 1 | iphone developer george something planet letter | ++------+-------------------------------------------------+ +––– input ––– +mysql -P9306 -h0 -e "drop table t" +––– output ––– From 2906e6d48922a06ebec3a472893a39025cdee4ce Mon Sep 17 00:00:00 2001 From: Pavel_Shilin Date: Mon, 17 Nov 2025 19:52:42 +0100 Subject: [PATCH 2/4] test: used same keywords with different force_bigrams values for comparison --- ...ec => call-autocomplete-force-bigrams.rec} | 100 +++++++----------- 1 file changed, 41 insertions(+), 59 deletions(-) rename test/clt-tests/core/{call-autocomplete-force-bigrams-vertical.rec => call-autocomplete-force-bigrams.rec} (60%) diff --git a/test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec b/test/clt-tests/core/call-autocomplete-force-bigrams.rec similarity index 60% rename from test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec rename to test/clt-tests/core/call-autocomplete-force-bigrams.rec index 8eb1ccbb57..94715206d9 100644 --- a/test/clt-tests/core/call-autocomplete-force-bigrams-vertical.rec +++ b/test/clt-tests/core/call-autocomplete-force-bigrams.rec @@ -3,9 +3,9 @@ Test for force_bigrams option in CALL AUTOCOMPLETE, CALL SUGGEST, and fuzzy sear 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-14): suggestions with bigram-based fuzzy matching -3. SELECT with OPTION fuzzy=1 (tests 15-19): regular search with fuzzy option +1. CALL AUTOCOMPLETE (tests 1-8): autocomplete with bigram-based fuzzy matching +2. CALL SUGGEST (tests 9-13): suggestions with bigram-based fuzzy matching +3. SELECT with OPTION fuzzy=1 (tests 14-18): regular search with fuzzy option The force_bigrams option helps find transposition errors (e.g., "ipohne" -> "iphone") in longer words where bigrams are not used by default. @@ -17,7 +17,7 @@ mysql -P9306 -h0 -e "drop table if exists t" 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 developer george something planet letter')" +mysql -P9306 -h0 -e "insert into t values(1,'iphone george planet letter')" ––– output ––– ––– comment ––– Test 1: force_bigrams=1 finds transposition errors @@ -32,56 +32,47 @@ Test 2: force_bigrams=0 does NOT find transpositions in long words mysql -P9306 -h0 -e "call autocomplete('ipohne', 't', 0 as force_bigrams)\G" ––– output ––– ––– comment ––– -Test 3: Long word transposition + force_bigrams -––– input ––– -mysql -P9306 -h0 -e "call autocomplete('develepor', 't', 1 as force_bigrams)\G" -––– output ––– -*************************** 1. row *************************** -query: developer -––– comment ––– -Test 4: Transposition in middle +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 5: Another transposition +Test 4: Same word with force_bigrams=0 - does NOT find transposition ––– input ––– -mysql -P9306 -h0 -e "call autocomplete('somtehing', 't', 1 as force_bigrams)\G" +mysql -P9306 -h0 -e "call autocomplete('geroge', 't', 0 as force_bigrams)\G" ––– output ––– -*************************** 1. row *************************** -query: something ––– comment ––– -Test 6: Short word - bigrams automatic +Test 5: Short word - bigrams automatic ––– input ––– mysql -P9306 -h0 -e "call autocomplete('lanet', 't', 0 as force_bigrams)\G" ––– output ––– *************************** 1. row *************************** query: planet ––– comment ––– -Test 7: Append option +Test 6: Append option ––– 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 +Test 7: Prepend option ––– 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 +Test 8: Multiple options ––– 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 - finds transpositions (SUGGEST is fuzzy by default) +Test 9: CALL SUGGEST with force_bigrams=1 - finds transpositions (SUGGEST is fuzzy by default) ––– input ––– mysql -P9306 -h0 -e "call suggest('ipohne', 't', 1 as force_bigrams)\G" ––– output ––– @@ -94,30 +85,26 @@ distance: 2 distance: 4 docs: 1 ––– comment ––– -Test 11: CALL SUGGEST with force_bigrams=0 - may not find transpositions in long words +Test 10: CALL SUGGEST with force_bigrams=0 - may not find transpositions in long words ––– input ––– mysql -P9306 -h0 -e "call suggest('ipohne', 't', 0 as force_bigrams)\G" ––– output ––– ––– comment ––– -Test 12: CALL SUGGEST with force_bigrams=1 - long word transposition +Test 11: CALL SUGGEST with force_bigrams=1 - transposition ––– input ––– -mysql -P9306 -h0 -e "call suggest('develepor', 't', 1 as force_bigrams)\G" +mysql -P9306 -h0 -e "call suggest('geroge', 't', 1 as force_bigrams)\G" ––– output ––– *************************** 1. row *************************** - suggest: developer + suggest: george distance: 2 docs: 1 ––– comment ––– -Test 13: CALL SUGGEST with force_bigrams=1 - another transposition +Test 12: Same word with force_bigrams=0 - does NOT find transposition ––– input ––– -mysql -P9306 -h0 -e "call suggest('geroge', 't', 1 as force_bigrams)\G" +mysql -P9306 -h0 -e "call suggest('geroge', 't', 0 as force_bigrams)\G" ––– output ––– -*************************** 1. row *************************** - suggest: george -distance: 2 - docs: 1 ––– comment ––– -Test 14: CALL SUGGEST with force_bigrams=0 - short word (bigrams automatic) +Test 13: CALL SUGGEST with force_bigrams=0 - short word (bigrams automatic) ––– input ––– mysql -P9306 -h0 -e "call suggest('lanet', 't', 0 as force_bigrams)\G" ––– output ––– @@ -130,50 +117,45 @@ distance: 1 distance: 4 docs: 1 ––– comment ––– -Test 15: SELECT with OPTION fuzzy=1, force_bigrams=1 - finds transposition errors +Test 14: SELECT with OPTION fuzzy=1, force_bigrams=1 - finds transposition errors ––– input ––– mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force_bigrams=1" ––– output ––– -+------+-------------------------------------------------+ -| id | f | -+------+-------------------------------------------------+ -| 1 | iphone developer george something planet letter | -+------+-------------------------------------------------+ ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ ––– comment ––– -Test 16: SELECT with OPTION fuzzy=1, force_bigrams=0 - may not find transpositions in long words +Test 15: SELECT with OPTION fuzzy=1, force_bigrams=0 - may not find transpositions in long words ––– input ––– mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force_bigrams=0" ––– output ––– ––– comment ––– -Test 17: SELECT with OPTION fuzzy=1, force_bigrams=1 - long word transposition +Test 16: SELECT with OPTION fuzzy=1, force_bigrams=1 - transposition ––– input ––– -mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('develepor') OPTION fuzzy=1, force_bigrams=1" +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force_bigrams=1" ––– output ––– -+------+-------------------------------------------------+ -| id | f | -+------+-------------------------------------------------+ -| 1 | iphone developer george something planet letter | -+------+-------------------------------------------------+ ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ ––– comment ––– -Test 18: SELECT with OPTION fuzzy=1, force_bigrams=1 - another transposition +Test 17: Same word with force_bigrams=0 - does NOT find transposition ––– input ––– -mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force_bigrams=1" +mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force_bigrams=0" ––– output ––– -+------+-------------------------------------------------+ -| id | f | -+------+-------------------------------------------------+ -| 1 | iphone developer george something planet letter | -+------+-------------------------------------------------+ ––– comment ––– -Test 19: SELECT with OPTION fuzzy=1, force_bigrams=0 - short word (bigrams automatic) +Test 18: SELECT with OPTION fuzzy=1, force_bigrams=0 - short word (bigrams automatic) ––– input ––– mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('lanet') OPTION fuzzy=1, force_bigrams=0" ––– output ––– -+------+-------------------------------------------------+ -| id | f | -+------+-------------------------------------------------+ -| 1 | iphone developer george something planet letter | -+------+-------------------------------------------------+ ++------+-----------------------------+ +| id | f | ++------+-----------------------------+ +| 1 | iphone george planet letter | ++------+-----------------------------+ ––– input ––– mysql -P9306 -h0 -e "drop table t" ––– output ––– From f6328d13a6ef7a2dca11e57a41f78058f625f992 Mon Sep 17 00:00:00 2001 From: Pavel_Shilin Date: Wed, 19 Nov 2025 18:34:41 +0100 Subject: [PATCH 3/4] Added paired tests for force_bigrams with automatic bigram selection, Clarify comments for automatic bigram selection tests --- .../core/call-autocomplete-force-bigrams.rec | 68 +++++++++++++------ 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/test/clt-tests/core/call-autocomplete-force-bigrams.rec b/test/clt-tests/core/call-autocomplete-force-bigrams.rec index 94715206d9..f3db5fc757 100644 --- a/test/clt-tests/core/call-autocomplete-force-bigrams.rec +++ b/test/clt-tests/core/call-autocomplete-force-bigrams.rec @@ -3,12 +3,9 @@ Test for force_bigrams option in CALL AUTOCOMPLETE, CALL SUGGEST, and fuzzy sear 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-8): autocomplete with bigram-based fuzzy matching -2. CALL SUGGEST (tests 9-13): suggestions with bigram-based fuzzy matching -3. SELECT with OPTION fuzzy=1 (tests 14-18): regular search with fuzzy option - -The force_bigrams option helps find transposition errors (e.g., "ipohne" -> "iphone") -in longer words where bigrams are not used by default. +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" @@ -44,35 +41,43 @@ Test 4: Same word with force_bigrams=0 - does NOT find transposition mysql -P9306 -h0 -e "call autocomplete('geroge', 't', 0 as force_bigrams)\G" ––– output ––– ––– comment ––– -Test 5: Short word - bigrams automatic +Test 5: 6-char word "planet" (boundary case), force_bigrams=0, expect: found +Note: "lanet" (5 chars) uses bigrams automatically, so it can match "planet" (6 chars) ––– input ––– mysql -P9306 -h0 -e "call autocomplete('lanet', 't', 0 as force_bigrams)\G" ––– output ––– *************************** 1. row *************************** query: planet ––– comment ––– -Test 6: Append option +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 7: Prepend option +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 8: Multiple options +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 9: CALL SUGGEST with force_bigrams=1 - finds transpositions (SUGGEST is fuzzy by default) +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 ––– @@ -85,12 +90,12 @@ distance: 2 distance: 4 docs: 1 ––– comment ––– -Test 10: CALL SUGGEST with force_bigrams=0 - may not find transpositions in long words +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 11: CALL SUGGEST with force_bigrams=1 - transposition +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 ––– @@ -99,12 +104,12 @@ mysql -P9306 -h0 -e "call suggest('geroge', 't', 1 as force_bigrams)\G" distance: 2 docs: 1 ––– comment ––– -Test 12: Same word with force_bigrams=0 - does NOT find transposition +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 13: CALL SUGGEST with force_bigrams=0 - short word (bigrams automatic) +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 ––– @@ -117,7 +122,20 @@ distance: 1 distance: 4 docs: 1 ––– comment ––– -Test 14: SELECT with OPTION fuzzy=1, force_bigrams=1 - finds transposition errors +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 ––– @@ -127,12 +145,12 @@ mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('ipohne') OPTION fuzzy=1, force | 1 | iphone george planet letter | +------+-----------------------------+ ––– comment ––– -Test 15: SELECT with OPTION fuzzy=1, force_bigrams=0 - may not find transpositions in long words +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 16: SELECT with OPTION fuzzy=1, force_bigrams=1 - transposition +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 ––– @@ -142,12 +160,12 @@ mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('geroge') OPTION fuzzy=1, force | 1 | iphone george planet letter | +------+-----------------------------+ ––– comment ––– -Test 17: Same word with force_bigrams=0 - does NOT find transposition +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 18: SELECT with OPTION fuzzy=1, force_bigrams=0 - short word (bigrams automatic) +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 ––– @@ -156,6 +174,16 @@ mysql -P9306 -h0 -e "SELECT * FROM t WHERE MATCH('lanet') OPTION fuzzy=1, force_ +------+-----------------------------+ | 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 ––– From cb89b7ef043947ca8fe55fbada3fa8d3c082bb1d Mon Sep 17 00:00:00 2001 From: Pavel_Shilin Date: Mon, 24 Nov 2025 22:53:00 +0100 Subject: [PATCH 4/4] Clarify that Test 5 finds "planet" from "lanet" not because both use bigrams, but because fuzzy matching works despite different n-grams (bigrams vs trigrams) due to small edit distance. --- test/clt-tests/core/call-autocomplete-force-bigrams.rec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/clt-tests/core/call-autocomplete-force-bigrams.rec b/test/clt-tests/core/call-autocomplete-force-bigrams.rec index f3db5fc757..9f95c607e8 100644 --- a/test/clt-tests/core/call-autocomplete-force-bigrams.rec +++ b/test/clt-tests/core/call-autocomplete-force-bigrams.rec @@ -42,7 +42,7 @@ 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" (5 chars) uses bigrams automatically, so it can match "planet" (6 chars) +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 –––