-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
library.py: search() - fts5 search improvement for keywords shorter t… #452
Conversation
@whmountains can you give this a shot? |
Thanks for this @chmorgan I may be doing something wrong, but it's not working for me. When I type in a two-letter query, it continues displaying the results of the previous, longer query. I added some some logging to find the problem:
Something funny is going on when there is nothing to match.: |
Doh, I’ll fix tonight. We may be assuming there is always a match term.
Thanks for the test run.
…On Thu, Apr 25, 2024 at 11:13 AM Caleb Whiting ***@***.***> wrote:
Thanks for this @chmorgan <https://github.com/chmorgan>
I may be doing something wrong, but it's not working for me. When I type
in a two-letter query, it continues displaying the results of the previous,
longer query.
I added some some logging to find the problem:
2024.04.25 10:09:26 - INFO - search - evaluating keyword `2k`
2024.04.25 10:09:26 - INFO - search - using LIKE query for `2k`: `AND description LIKE '%2k%'`
2024.04.25 10:09:26 - INFO - search - Executing query: SELECT "LCSC Part","MFR.Part","Package","Solder Joint","Library Type","Stock","Manufacturer","Description","Price" FROM parts WHERE parts MATCH ''AND description LIKE '%2k%' AND "Library Type" IN ("Basic") ORDER BY "LCSC Part" COLLATE naturalsort ASC LIMIT 1000
Traceback (most recent call last):
File "/Users/cw/Documents/KiCad/8.0/scripting/plugins/chmorgan-kicad-tools/partselector.py", line 587, in search
result = self.parent.library.search(parameters)
File "/Users/cw/Documents/KiCad/8.0/scripting/plugins/chmorgan-kicad-tools/library.py", line 218, in search
return cur.execute(query).fetchall()
sqlite3.OperationalError: fts5: syntax error near ""
Something funny is going on when there is nothing to match.: WHERE parts
MATCH ''AND
—
Reply to this email directly, view it on GitHub
<#452 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJH4AG74OCNZDHHY72NE6DY7EMPZAVCNFSM6AAAAABGX4NKM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZXGUZDSMBTHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
…han 3 unicode characters FTS5 'match' only evaluates substrings longer than 3 unicode characters, searching for shorter substrings results in no matches being returned. Fixes an issue where attempting to search for substrings shorter than 3 characters was resulting in empty search results. Add "AND description LIKE '%SUBSTRING%'" terms for each substring shorter than 3 characters.
@whmountains alright, updated and should fix the issue you saw. |
@whmountains ping on whether this addresses your issues. Would like to get it merged in for quality of life improvements for anyone using the plugin. |
Can confirm this PR now works correctly with searches less than 3 chars. |
Any updates on this @Bouni ? Would like to get this and the other PR merged for quality of use improvements for present users. |
No, I'm on vacation at the moment. Will be back next week |
Ahh ok, np, have a good vacation!
…On Mon, May 6, 2024 at 7:23 AM bouni ***@***.***> wrote:
No, I'm on vacation at the moment. Will be back next week
—
Reply to this email directly, view it on GitHub
<#452 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJH4ABVNXFCTAKKNUODNMLZA5R2DAVCNFSM6AAAAABGX4NKM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVG44DONBTGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
LGTM |
…han 3 unicode characters
FTS5 'match' only evaluates substrings longer than 3 unicode characters, searching for shorter substrings results in no matches being returned.
Fixes an issue where attempting to search for substrings shorter than 3 characters was resulting in empty search results.
Add "AND description LIKE '%SUBSTRING%'" terms for each substring shorter than 3 characters.