Open Zerrisx opened 4 years ago
Any chance you know where in the code the database queries are formed? I'm looking into this but its taking awhile to find the right place.
Alas not; I'm not a developer and don't know the code well enough.
You're probably looking for CardSelector.filterCards().
Thanks for the help!@emerald000
After looking into it, it seams the search is returning all 40958 cards from the database before filtering gives the final results no matter what is typed into the search box. This can be seen by counting the difference in results from line 438 of CardSelector.java:
java.util.List<CardInfo> foundCards = CardRepository.instance.findCards(buildCriteria());
and the number of filtered cards returned in filteredCards
.
At this point, I'm still investigating. However, I guess that fuzzy matching will be much more difficult by filtering. There seems to be lots of documentation on how to do it constructively from the database querying approach. Also, performance of the search would likely increase if a more targeted query could be made.
My questions for the community:
XMage uses autogenerated SQL queries to load cards from inner database. It's limited to search and filter (and limited to indexes too). That's why it uses runtime filter
to search any data from card. So the main idea of current search logic: search cards for basic data by database and filter results with more accurate runtime code.
So you can modify CardTextPredicate
to add lazy logic to search. As example:
Currently, if you search for:
"Jace the"
there will be no matches, even though it's fairly clear to a human that you would have liked to find:
"Jace, the Living Guild Pact" "Jace, the Mind Sculptor"
Can we make the search ignore missing punctuation when returning results?
As a bonus, it might also be nice if:
"Mindsculptor"
could find
"Jace, the Mind Sculptor"
i.e. be spacing ambivalent as well