Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions nbs/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down