Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 075f018

Browse files
edits
1 parent 9c55602 commit 075f018

File tree

3 files changed

+48
-43
lines changed

3 files changed

+48
-43
lines changed

src/content/docs/client-apis/wasm.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ browsers.
99

1010
## Benefits of WASM
1111

12-
Kùzu-Wasm enables the following:
12+
Several benefits of Kùzu-Wasm are the following:
1313

14-
- Fast, in-browser graph analysis without ever sending data to a server
15-
- Strong data privacy guarantees, as the data never leaves the browser
16-
- Real-time interactive dashboards
17-
- Lightweight, portable solutions that leverage graphs within web applications
14+
- Fast, in-browser graph analysis without ever sending data to a server.
15+
- Strong data privacy guarantees, as the data never leaves the browser.
16+
- Real-time interactive in-browser graph analytics and visualization.
1817

1918
## Installation
2019

@@ -101,7 +100,7 @@ This script can be directly embedded in an HTML file, for example:
101100
## Understanding the package
102101

103102
In this package, three different variants of WebAssembly modules are provided:
104-
- **Default**: This is the default build of the WebAssembly module. It does not support multi-threading and uses Emscripten's default filesystem. This build has the smallest size and works in both Node.js and browser environments. It has the best compatibility and does not require cross-origin isolation. However, the performance maybe limited due to the lack of multithreading support. This build is located at the root level of the package.
103+
- **Default**: This is the default build of the WebAssembly module. It does not support multi-threading and uses Emscripten's default filesystem. This build has the smallest size and works in both Node.js and browser environments. It has the best compatibility and does not require cross-origin isolation. However, the performance may be limited due to the lack of multithreading support. This build is located at the root level of the package.
105104
- **Multi-threaded**: This build supports multi-threading and uses Emscripten's default filesystem. This build has a larger size compared to the default build and only requires [cross-origin isolation](https://web.dev/articles/cross-origin-isolation-guide) in the browser environment. This build is located in the `multithreaded` directory.
106105
- **Node.js**: This build is optimized for Node.js and uses Node.js's filesystem instead of Emscripten's default filesystem (`NODEFS` flag is enabled). This build also supports multi-threading. It is distributed as a CommonJS module rather than an ES module to maximize compatibility. This build is located in the `nodejs` directory. Note that this build only works in Node.js and does not work in the browser environment.
107106

src/content/docs/extensions/full-text-search.md

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ title: "Full Text Search"
44

55
## Usage
66

7-
The `FTS` (full-text search) extension adds support for matching within the content of a string property
7+
The full-text search (`FTS`) extension adds support for matching within the content of a string property
88
while returning the documents with a proximity score to the query. It is enabled by building an index
99
on string properties in a table and allows searching through the strings via a keyword query.
1010
Currently, Kùzu supports only indexing on a node table's `STRING` properties.
1111

12-
The FTS functionality is not available by default, so you would first need to install the `FTS`
12+
The FTS functionality is not available by default, so you first need to install the `FTS`
1313
extension by running the following commands:
1414

1515
```sql
@@ -31,46 +31,45 @@ CREATE (b:Book {abstract: 'A deep dive into the history of ancient civilizations
3131
CREATE (b:Book {abstract: 'A fantasy tale of dragons and magic.', author: 'Charlotte Harris', title: 'The Dragon\'s Call'});
3232
```
3333

34-
In the following sections, we will build a full-text search index on the book table, and demonstrate how to search for books relevant to a keyword query.
35-
34+
In the following sections, we show how to build and query a full-text search index on the book table.
3635
### Create FTS index
3736

3837
Kùzu provides a function `CREATE_FTS_INDEX` to create the full-text search index on a table:
3938

4039
```cypher
4140
CALL CREATE_FTS_INDEX('TABLE_NAME', 'INDEX_NAME', ['PROP1', 'PROP2', 'PROP3'...], OPTIONAL_PARAM1 := 'OPTIONAL_VAL1')
4241
```
43-
- `TABLE_NAME`: The name of the table to build FTS index.
44-
- `INDEX_NAME`: The name of the FTS index to create.
45-
- `PROPERTIES`: A list of properties in the table to build FTS index on. Full text search will only search the properties with FTS index built on.
42+
- `TABLE_NAME`: The name of the table to build the FTS index on.
43+
- `INDEX_NAME`: The name of the created FTS index.
44+
- `PROPERTIES`: The list of properties in the table to build the FTS index on. The strings in these
45+
properties will be tokenized and indexed. The FTS index will only match keywords across
46+
these indexed properties.
4647

4748
The following optional parameters are supported:
4849

4950
- `stemmer`: The text normalization technique to use. Should be one of: `arabic`, `basque`, `catalan`, `danish`, `dutch`, `english`, `finnish`, `french`, `german`, `greek`, `hindi`, `hungarian`, `indonesian`, `irish`, `italian`, `lithuanian`, `nepali`, `norwegian`, `porter`, `portuguese`, `romanian`, `russian`, `serbian`, `spanish`, `swedish`, `tamil`, `turkish`, or `none` if no stemming is to be used. Defaults to `english`,
5051
which uses a Snowball stemmer.
5152

52-
The example below shows how to create an FTS index on the book table with the `abstract`, `author` and `title` properties using the `porter` stemmer.
53+
The example below shows how to create an FTS index on the book table with the `abstract`, `author`, and `title` properties using the `porter` stemmer.
5354

5455
:::caution[Note]
55-
Kùzu uses special syntax for optional parameters. Note how the `:=` operator is used to assign a value
56+
Syntax of optional parameters: Kùzu uses special syntax for optional parameters. Note how the `:=` operator is used to assign a value
5657
to an optional parameter in the example below.
5758
:::
5859

5960
```cypher
6061
CALL CREATE_FTS_INDEX(
61-
'Book', // Table name
62-
'book_index', // Index name
63-
['abstract', 'author', 'title'], // Properties to build FTS index on
64-
stemmer := 'porter' // Stemmer to use (optional)
62+
'Book', // Table name
63+
'book_index', // Index name
64+
['abstract', 'author', 'title'], // Properties to build FTS index on
65+
stemmer := 'porter' // Stemmer to use (optional)
6566
)
6667
```
67-
68-
Depending on the size of the dataset, the index creation may take some time. Once the index creation is complete,
69-
the index will be ready to use for full-text search.
68+
Once the index is created, the index will be ready for querying as shown below.
7069

7170
### Query FTS index
7271

73-
Kùzu provides a table function `QUERY_FTS_INDEX` to query the FTS index on a table using the [Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25) scoring algorithm:
72+
Kùzu provides the `QUERY_FTS_INDEX` function to query the FTS index on a table using the [Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25) scoring algorithm:
7473

7574
```cypher
7675
CALL QUERY_FTS_INDEX(
@@ -80,17 +79,22 @@ CALL QUERY_FTS_INDEX(
8079
OPTIONAL_PARAM1 := 'OPTIONAL_VAL1'...
8180
)
8281
```
83-
- `TABLE_NAME`: The name of the table to query
84-
- `INDEX_NAME`: The name of the FTS index to query
85-
- `QUERY`: The query string
82+
- `TABLE_NAME`: The name of the table to query.
83+
- `INDEX_NAME`: The name of the FTS index to query.
84+
- `QUERY`: The query string that contains the keywords to search.
8685

86+
:::caution[Note]
87+
Uniqueness of index names: If you build multiple FTS indices on a table, they
88+
must have different names. However, multiple FTS indices can have the same
89+
name as long as each one is built on a separate table.
90+
:::
8791
The following optional parameters are supported:
8892

89-
1. `conjunctive`: Whether all keywords in the query should appear in order for a document to be retrieved, default to false.
90-
2. `K`: parameter controls the influence of term frequency saturation. It limits the effect of additional occurrences of a term within a document. Defaults to 1.2.
91-
3. `B`: parameter controls the degree of length normalization by adjusting the influence of document length. Defaults to 0.75.
93+
1. `conjunctive`: Whether all keywords in the query should appear in order for a document to be retrieved. Defaults to false.
94+
2. `K`: controls the influence of term frequency saturation. This limits the effect of additional occurrences of a term within a document. Defaults to 1.2.
95+
3. `B`: controls the degree of length normalization by adjusting the influence of document length. Defaults to 0.75.
9296

93-
Detailed explanation of k and b values can be found [there](https://learn.microsoft.com/en-us/azure/search/index-ranking-similarity)
97+
Detailed explanation of k and b values can be found [here](https://learn.microsoft.com/en-us/azure/search/index-ranking-similarity).
9498

9599
The below example shows how to query books related to the `quantum machine` and order the books by their scores:
96100
```cypher
@@ -161,14 +165,14 @@ CALL DROP_FTS_INDEX('Book', 'book_index')
161165

162166
### Show FTS indexes
163167

164-
There is no function specifically to show FTS indexes, but there is a general function [`SHOW_INDEXES`](/cypher/query-clauses/call) that
168+
There is no function to specifically show FTS indexes, but there is a general function [`SHOW_INDEXES`](/cypher/query-clauses/call) that
165169
can be used to show all the indexes available in the database.
166170

167171
```cypher
168172
CALL SHOW_INDEXES() RETURN *;
169173
```
170174
This will return a list of all the indexes available in the database, while also listing the type of each
171-
index. Scan the table to find the FTS indexes that are currently available.
175+
index.
172176

173177
```
174178
┌────────────┬─────────────┬────────────┬─────────────────────────┬──────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────┐
@@ -182,21 +186,20 @@ index. Scan the table to find the FTS indexes that are currently available.
182186
### Prepared statement
183187

184188
[Prepared statements](/get-started/prepared-statements) allows you to execute a query with different parameter values without rebinding the same query.
185-
A typical use case where parameters are useful is when you want to find books with different contents.
186-
187-
Example:
188-
Let's start with preparing a cypher statement which queries the `book_index`.
189+
You can parameterize your `CALL QUERY_FTS_INDEX` calls. For example,
190+
suppose you want to find books with different keywords. We give
191+
an example below using our C++ API but you can create prepared statements in other APIs as well.
192+
We first prepare a Cypher statement which queries the `book_index` with a parameter `q`.
189193
```c++
190194
auto preparedStatement = conn->prepare("CALL QUERY_FTS_INDEX('Book', 'book_index', $q) RETURN node.ID, score;");
191195
```
192-
Now, we can find books with different contents using the prepared statement without rebinding.
193-
194-
#### Find books related to `machine learning`
196+
Now, we can find books with different keywords using the prepared statement and
197+
specifying different values for `q`. For example, to query the index with keywords `machine learning`, we can do:
195198
```c++
196199
auto result = conn->execute(prepared.get, std::make_pair(std::string("q"), std::string("machine learning")));
197200
```
198201

199-
#### Find books related to `dragons`
202+
Similarly, to query the index with the keyword `dragons`, we can do:
200203
```c++
201204
auto result = conn->execute(prepared.get, std::make_pair(std::string("q"), std::string("dragons")));
202205
```

src/content/docs/get-started/prepared-statements.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "Run prepared Cypher statements"
55
Just like we have [SQL injection](https://en.wikipedia.org/wiki/SQL_injection) in relational databases,
66
we can also have Cypher injection in graph databases. This is when a user can manipulate the query
77
to execute arbitrary code that can threaten the integrity of the data. As a best practice, it's
8-
generally to provide parameters to your Cypher queries instead of using string literals in your code.
8+
generally a good idea to provide parameters to your Cypher queries instead of using string literals in your code.
99

1010
This section shows to run *prepared* Cypher statements with parameters while working with a client
1111
API in Kùzu.
@@ -17,7 +17,7 @@ Instead of hardcoding the age value into a Cypher query, it would make more sens
1717
to the query, so that the same query can be reused for other values.
1818

1919
Another situation where parameters are useful is when you want to loop through a list of records and
20-
write each record to the database. Because records may have differnt values for a given property, it's
20+
write each record to the database. Because records may have different values for a given property, it's
2121
a good idea to use parameters to provide the values dynamically.
2222

2323
## Syntax
@@ -65,6 +65,9 @@ conn.execute(
6565
"""
6666
)
6767
```
68-
68+
:::caution[Note]
69+
You can also use provide parameters to `CALL QUERY_FTS_INDEX(...)` function calls.
70+
See the documentation on [FTS Index](/extensions/full-text-search#prepared-statement) for more details.
71+
:::
6972

7073

0 commit comments

Comments
 (0)