{"database": "docs", "table": "sections", "is_view": false, "human_description_en": "where breadcrumbs = \"[\"Full-text search\", \"Enabling full-text search for a SQLite table\"]\" and breadcrumbs contains \"Full-text search\"", "rows": [["full_text_search:configuring-fts-by-hand", "full_text_search", "configuring-fts-by-hand", "Configuring FTS by hand", "We recommend using  sqlite-utils , but if you want to hand-roll a SQLite full-text search table you can do so using the following SQL. \n                 To enable full-text search for a table called  items  that works against the  name  and  description  columns, you would run this SQL to create a new  items_fts  FTS virtual table: \n                 CREATE VIRTUAL TABLE \"items_fts\" USING FTS4 (\n    name,\n    description,\n    content=\"items\"\n); \n                 This creates a set of tables to power full-text search against  items . The new  items_fts  table will be detected by Datasette as the  fts_table  for the  items  table. \n                 Creating the table is not enough: you also need to populate it with a copy of the data that you wish to make searchable. You can do that using the following SQL: \n                 INSERT INTO \"items_fts\" (rowid, name, description)\n    SELECT rowid, name, description FROM items; \n                 If your table has columns that are foreign key references to other tables you can include that data in your full-text search index using a join. Imagine the  items  table has a foreign key column called  category_id  which refers to a  categories  table - you could create a full-text search table like this: \n                 CREATE VIRTUAL TABLE \"items_fts\" USING FTS4 (\n    name,\n    description,\n    category_name,\n    content=\"items\"\n); \n                 And then populate it like this: \n                 INSERT INTO \"items_fts\" (rowid, name, description, category_name)\n    SELECT items.rowid,\n    items.name,\n    items.description,\n    categories.name\n    FROM items JOIN categories ON items.category_id=categories.id; \n                 You can use this technique to populate the full-text search index from any combination of tables and joins that makes sense for your project.", "[\"Full-text search\", \"Enabling full-text search for a SQLite table\"]", "[{\"href\": \"https://sqlite-utils.datasette.io/\", \"label\": \"sqlite-utils\"}]"], ["full_text_search:configuring-fts-using-csvs-to-sqlite", "full_text_search", "configuring-fts-using-csvs-to-sqlite", "Configuring FTS using csvs-to-sqlite", "If your data starts out in CSV files, you can use Datasette's companion tool  csvs-to-sqlite  to convert that file into a SQLite database and enable full-text search on specific columns. For a file called  items.csv  where you want full-text search to operate against the  name  and  description  columns you would run the following: \n                 $ csvs-to-sqlite items.csv items.db -f name -f description", "[\"Full-text search\", \"Enabling full-text search for a SQLite table\"]", "[{\"href\": \"https://github.com/simonw/csvs-to-sqlite\", \"label\": \"csvs-to-sqlite\"}]"], ["full_text_search:configuring-fts-using-sqlite-utils", "full_text_search", "configuring-fts-using-sqlite-utils", "Configuring FTS using sqlite-utils", "sqlite-utils  is a CLI utility and Python library for manipulating SQLite databases. You can use  it from Python code  to configure FTS search, or you can achieve the same goal  using the accompanying command-line tool . \n                 Here's how to use  sqlite-utils  to enable full-text search for an  items  table across the  name  and  description  columns: \n                 $ sqlite-utils enable-fts mydatabase.db items name description", "[\"Full-text search\", \"Enabling full-text search for a SQLite table\"]", "[{\"href\": \"https://sqlite-utils.datasette.io/\", \"label\": \"sqlite-utils\"}, {\"href\": \"https://sqlite-utils.datasette.io/en/latest/python-api.html#enabling-full-text-search\", \"label\": \"it from Python code\"}, {\"href\": \"https://sqlite-utils.datasette.io/en/latest/cli.html#configuring-full-text-search\", \"label\": \"using the accompanying command-line tool\"}]"]], "truncated": false, "filtered_table_rows_count": 3, "expanded_columns": [], "expandable_columns": [], "columns": ["id", "page", "ref", "title", "content", "breadcrumbs", "references"], "primary_keys": ["id"], "units": {}, "query": {"sql": "select id, page, ref, title, content, breadcrumbs, [references] from sections where \"breadcrumbs\" = :p0 and :p1 in (select value from json_each([sections].[breadcrumbs])) order by id limit 101", "params": {"p0": "[\"Full-text search\", \"Enabling full-text search for a SQLite table\"]", "p1": "Full-text search"}}, "facet_results": {}, "suggested_facets": [{"name": "breadcrumbs", "type": "array", "toggle_url": "https://stable-docs.datasette.io/docs/sections.json?breadcrumbs=%5B%22Full-text+search%22%2C+%22Enabling+full-text+search+for+a+SQLite+table%22%5D&breadcrumbs__arraycontains=Full-text+search&_facet_array=breadcrumbs"}], "next": null, "next_url": null, "private": false, "allow_execute_sql": true, "query_ms": 24.274265044368804}