Skip to content
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

Support for ?_search_colname=blah searches #237

Closed
simonw opened this issue Apr 25, 2018 · 2 comments
Closed

Support for ?_search_colname=blah searches #237

simonw opened this issue Apr 25, 2018 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Apr 25, 2018

Right now the _search= argument searches across all fields in a full-text index, for example:

https://san-francisco.datasettes.com/sf-film-locations-84594a7/Film_Locations_in_San_Francisco?_search=justin

SQLite FTS also supports searches within a specified field, for example:

https://san-francisco.datasettes.com/sf-film-locations-84594a7?sql=select+rowid%2C+*+from+Film_Locations_in_San_Francisco+where+rowid+in+%28select+rowid+from+%5BFilm_Locations_in_San_Francisco_fts%5D+where+%5BLocations%5D+match+%3Asearch%29+order+by+rowid+limit+101&search=justin

select rowid, * from Film_Locations_in_San_Francisco
where rowid in (
  select rowid from [Film_Locations_in_San_Francisco_fts]
  where [Locations] match :search
) order by rowid limit 101

The _search= parameter could be extended to support this using _search_colname=.

This should also be able to support columns with spaces and special characters in their names, something like this:

_search_Column%20With%20Spaces=foo

@simonw
Copy link
Owner Author

simonw commented May 5, 2018

@simonw
Copy link
Owner Author

simonw commented May 5, 2018

Demo:

datasette publish now ../datasettes/san-francisco/sf-film-locations.db --branch=master --name datasette-column-search-demo

https://datasette-column-search-demo.now.sh/sf-film-locations/Film_Locations_in_San_Francisco?_search_Locations=justin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant