Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow multiple keywords in crate search #1543
jtgeibel left a comment
Thanks for the PR @pwoolcoc! It looks like you need to run
I've been slowly working on moving this pull request forward by changing the query to return crates that have all the keywords specified, rather than any. So far all I've been successful at accomplishing is merging in master to resolve the merge conflicts and adding a failing test for the ALL functionality.
I've been attempting to turn the pseudocode sketch in this comment into a working diesel query, but I have been unsuccessful. I have a runnable reproduction of the issue extracted into a smaller codebase showing the set of diesel queries I've tried along with notes on why they didn't work in this repo.
I would drop into raw sql, but I don't want to lose the automatic escaping of the queried keywords to prevent against SQLI. I don't know how to generate just an escaped SQL string and insert it into a raw SQL query.
I'm now at a complete loss of how to proceed, and I think this PR is going to need your help to unblock, @sgrif.
The backend API requests are working, but there is no way to interact with this via the frontend. I'm going to make a param named
Diesel has a bug where array expression methods aren't implemented on nullable expressions, so we can't just call Diesel's `.contains` method until the fix lands. I've added a workaround for the time being. This results in a runtime error since `keyword` was defined as `varchar`, which coerces to `text`, but arrays do not. I've changed the column type to address this. The keywords table is small enough and read infrequently enough that I'm not concerned about the exclusive lock in this migration.
Pass along any specified value for the all_keywords parameter to the API request to search crates. This lets us manually construct URLs in the browser like: - /search?all_keywords=foo+bar - /search?all_keywords=foo+bar&q=test but there is no form field in the search form as yet; eventually, we'll need an "advanced search" form or similar.