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

UI support for running FTS searches #131

Closed
4 tasks done
simonw opened this issue Nov 19, 2017 · 3 comments
Closed
4 tasks done

UI support for running FTS searches #131

simonw opened this issue Nov 19, 2017 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Nov 19, 2017

Here's an example query that searches all FTS indexed columns in a table: https://sf-trees-search.now.sh/sf-trees-search-a899b92?sql=select+*+from+Street_Tree_List+where+rowid+in+%28select+rowid+from+Street_Tree_List_fts+where+Street_Tree_List_fts+match+%27grove+london+dpw%27%29%0D%0A

And here's a query that searches a specific column: https://sf-trees-search.now.sh/sf-trees-search-a899b92?sql=select+*+from+Street_Tree_List+where+rowid+in+%28select+rowid+from+Street_Tree_List_fts+where+qSpecies+match+%27london%27%29%0D%0A

If we detect that a table has FTS enabled (which we can do by looking for it as a content table reference in another FTS table's create definition) we should add a search box to the table page which constructs this query - maybe using ?_search=XXX in the query string?

To support search against specified columns, we can do ?_search__ qSpecies=London. - not necessary, see comment below.

  • Detect if a table has a FTS index defined against it as a content= parameter
  • Decide what to do if there is more than one FTS index (maybe just pick the first one?)
  • Add the ?_search= query string argument
  • Add the UI
@simonw simonw added this to the SQLite extensions + advanced JSON edition milestone Nov 19, 2017
simonw added a commit to simonw/csvs-to-sqlite that referenced this issue Nov 19, 2017
The --fts option will create a corresponding SQLite FTS virtual table, using
the best available version of the FTS module.

https://sqlite.org/fts5.html
https://www.sqlite.org/fts3.html

Usage:

    csvs-to-sqlite my-csv.csv output.db -f column1 -f column2

Example generated with this option: https://sf-trees-search.now.sh/

Example search: https://sf-trees-search.now.sh/sf-trees-search-a899b92?sql=select+*+from+Street_Tree_List+where+rowid+in+%28select+rowid+from+Street_Tree_List_fts+where+Street_Tree_List_fts+match+%27grove+london+dpw%27%29%0D%0A

Will be used in simonw/datasette#131
@simonw
Copy link
Owner Author

simonw commented Nov 19, 2017

@simonw
Copy link
Owner Author

simonw commented Nov 19, 2017

Since SQLite supports column specifications in the MATCH body itself, there's no need to provide a separate mechanism for specifying columns in the query string: https://sqlite.org/fts5.html#fts5_column_filters

@simonw simonw closed this as completed in eed6a0f Nov 19, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 19, 2017

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