You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: src/content/docs/client-apis/wasm.mdx
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,11 @@ browsers.
9
9
10
10
## Benefits of WASM
11
11
12
-
Kùzu-Wasm enables the following:
12
+
Several benefits of Kùzu-Wasm are the following:
13
13
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.
18
17
19
18
## Installation
20
19
@@ -101,7 +100,7 @@ This script can be directly embedded in an HTML file, for example:
101
100
## Understanding the package
102
101
103
102
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.
105
104
-**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.
106
105
-**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.
Copy file name to clipboardExpand all lines: src/content/docs/extensions/full-text-search.md
+37-34Lines changed: 37 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,12 @@ title: "Full Text Search"
4
4
5
5
## Usage
6
6
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
8
8
while returning the documents with a proximity score to the query. It is enabled by building an index
9
9
on string properties in a table and allows searching through the strings via a keyword query.
10
10
Currently, Kùzu supports only indexing on a node table's `STRING` properties.
11
11
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`
13
13
extension by running the following commands:
14
14
15
15
```sql
@@ -31,46 +31,45 @@ CREATE (b:Book {abstract: 'A deep dive into the history of ancient civilizations
31
31
CREATE (b:Book {abstract: 'A fantasy tale of dragons and magic.', author: 'Charlotte Harris', title: 'The Dragon\'s Call'});
32
32
```
33
33
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.
36
35
### Create FTS index
37
36
38
37
Kùzu provides a function `CREATE_FTS_INDEX` to create the full-text search index on a table:
-`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.
46
47
47
48
The following optional parameters are supported:
48
49
49
50
-`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`,
50
51
which uses a Snowball stemmer.
51
52
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.
53
54
54
55
:::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
56
57
to an optional parameter in the example below.
57
58
:::
58
59
59
60
```cypher
60
61
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)
65
66
)
66
67
```
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.
70
69
71
70
### Query FTS index
72
71
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:
74
73
75
74
```cypher
76
75
CALL QUERY_FTS_INDEX(
@@ -80,17 +79,22 @@ CALL QUERY_FTS_INDEX(
80
79
OPTIONAL_PARAM1 := 'OPTIONAL_VAL1'...
81
80
)
82
81
```
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.
86
85
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
+
:::
87
91
The following optional parameters are supported:
88
92
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.
92
96
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).
94
98
95
99
The below example shows how to query books related to the `quantum machine` and order the books by their scores:
@@ -182,21 +186,20 @@ index. Scan the table to find the FTS indexes that are currently available.
182
186
### Prepared statement
183
187
184
188
[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`.
189
193
```c++
190
194
auto preparedStatement = conn->prepare("CALL QUERY_FTS_INDEX('Book', 'book_index', $q) RETURN node.ID, score;");
191
195
```
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:
195
198
```c++
196
199
auto result = conn->execute(prepared.get, std::make_pair(std::string("q"), std::string("machine learning")));
197
200
```
198
201
199
-
#### Find books related to `dragons`
202
+
Similarly, to query the index with the keyword `dragons`, we can do:
200
203
```c++
201
204
auto result = conn->execute(prepared.get, std::make_pair(std::string("q"), std::string("dragons")));
0 commit comments