diff --git a/nbs/index.ipynb b/nbs/index.ipynb index f7a76ec..b15694f 100644 --- a/nbs/index.ipynb +++ b/nbs/index.ipynb @@ -419,6 +419,51 @@ "except ValueError as e:\n", " print(e)\n" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Full-text search" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's define a table `notes` with a field called `text` and enable full-text search on this field" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "notes = Table(db, 'notes')\n", + "notes = notes.create(columns=dict(id=int, content=str), pk=\"id\")\n", + "\n", + "notes.enable_fts([\"content\"], create_triggers=True)\n", + "\n", + "notes.insert(dict(content=\"hello\"))\n", + "notes.insert(dict(content=\"world\"))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "From now on, we expect to be able to use full text search using `search` function" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert len(list(notes.search(\"hello\", columns=[\"content\"]))) != 0" + ] } ], "metadata": {