From 73bb45bd94a0719e088d364e5f8f2147268ce123 Mon Sep 17 00:00:00 2001 From: Philip Nuzhnyi Date: Sat, 31 Aug 2024 13:28:18 +0100 Subject: [PATCH 1/2] demo full-text search issue --- nbs/index.ipynb | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/nbs/index.ipynb b/nbs/index.ipynb index f7a76ec..c468933 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(\"hell0\", columns=[\"content\"]))) != 0" + ] } ], "metadata": { From 8175b445ac80d04389014e9146470843a32c3d88 Mon Sep 17 00:00:00 2001 From: Philip Nuzhnyi Date: Sat, 31 Aug 2024 16:06:40 +0100 Subject: [PATCH 2/2] fix spelling --- nbs/index.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nbs/index.ipynb b/nbs/index.ipynb index c468933..b15694f 100644 --- a/nbs/index.ipynb +++ b/nbs/index.ipynb @@ -462,7 +462,7 @@ "metadata": {}, "outputs": [], "source": [ - "assert len(list(notes.search(\"hell0\", columns=[\"content\"]))) != 0" + "assert len(list(notes.search(\"hello\", columns=[\"content\"]))) != 0" ] } ],