Export to GitHub

mtg-familiar - issue #61

The search SQL query should be more flexible


Posted on Dec 9, 2011 by Massive Bear

What steps will reproduce the problem? 1. Go into Card Search 2. Search for "go throat"

What is the expected output? What do you see instead? It should probably find Go for the Throat, but it currently doesn't.

Currently, in meta-code, the SQL search is this: SELECT card WHERE cardname LIKE %query%

But it should probably split each word apart as such (for GftT): SELECT card WHERE (cardname LIKE %go%) AND (cardname LIKE %throat%)

Comment #1

Posted on Dec 9, 2011 by Massive Bear

Assigning to Alex. Thanks, Alex. :D

Comment #2

Posted on Dec 10, 2011 by Grumpy Rhino

After testing it in a SQLite equivalent of Microsoft SQL Server, I found that the easier form of "(cardname LIKE '%go%') AND (cardname LIKE '%throat%')" is simply "cardname LIKE '%go%throat%'". Using multiple wildcards like that works just fine. I added in a .replace(" ", "%") after the .trim() on the cardname field (so we don't sub in for trailing whitespace), and it works - searching "go throat" comes up with Go for the Throat. One thing to note, though: it can produce seemingly odd results (e.g. "go thr" comes up with "Go for the Throat" and "Goblin Deathraiders"). I assume we don't care, but I figured I'd mention it.

Comment #3

Posted on Dec 10, 2011 by Happy Horse

Changed it so order doesn't matter. Fixed in R139

Comment #4

Posted on Aug 16, 2012 by Happy Horse

(No comment was entered for this change.)

Status: Verified

Labels:
Type-Defect Priority-Medium