-
-
Notifications
You must be signed in to change notification settings - Fork 620
Add comprehensive tests for force_bigrams option #3909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
14fa292
Add comprehensive tests for force_bigrams in CALL SUGGEST, fuzzy sear…
PavelShilin89 2906e6d
test: used same keywords with different force_bigrams values for comp…
PavelShilin89 f6328d1
Added paired tests for force_bigrams with automatic bigram selection,…
PavelShilin89 cb89b7e
Clarify that Test 5 finds "planet" from "lanet" not because both use …
PavelShilin89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
189 changes: 189 additions & 0 deletions
189
test/clt-tests/core/call-autocomplete-force-bigrams.rec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" (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: 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 ––– | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.