-DATASET CSV fts-basic

--

-CASE Basic

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CALL _CREATE_FTS_INDEX('Book', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- error
Catalog exception: function _CREATE_FTS_INDEX does not exist.
-STATEMENT CALL CREATE_FTS_INDEX('Book', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'a quantum machine') RETURN node.title;
---- 2
The Quantum World
Learning Machines
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'history') RETURN node.title;
---- 1
Echoes of the Past
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'past magic world') RETURN node.title;
---- 4
The Quantum World
Echoes of the Past
Chronicles of the Universe
The Dragon's Call

# Build multiple FTS on the same table with same properties and query
-STATEMENT CALL CREATE_FTS_INDEX('Book', 'book_index_duplicate', ['abstract', 'author', 'title'], stemmer := 'porter');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_duplicate', 'the past magic world') RETURN node.title;
---- 4
The Quantum World
Echoes of the Past
Chronicles of the Universe
The Dragon's Call

# Build multiple FTS on the same table with different properties and query
-STATEMENT CALL CREATE_FTS_INDEX('Book', 'book_index_small', ['abstract'], stemmer := 'porter');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'a past magic world') RETURN node.title;
---- 2
Chronicles of the Universe
The Dragon's Call

-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', '') RETURN node.title;
---- 0
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'a an the') RETURN node.title;
---- 0
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'missing') RETURN node.title;
---- 0
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'johnson') RETURN node.title;
---- 2
The Quantum World
Echoes of the Past
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'johnson') RETURN node.title;
---- 0

-STATEMENT MATCH (b:Book) WHERE b.author = 'John Smith' DELETE b RETURN b.*;
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'past magic world') RETURN node.title;
---- 3
The Quantum World
Echoes of the Past
The Dragon's Call
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'a past magic world') RETURN node.title;
---- 1
The Dragon's Call

-STATEMENT MATCH (b:Book) DELETE b RETURN b.*;
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'past magic world') RETURN node.title;
---- 0
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'a past magic world') RETURN node.title;
---- 0

-STATEMENT CREATE (b:Book {abstract: 'A fantasy tale of dragons and magic.', author: 'J. K. Rowling', title: 'Harry Potter and the Goblet of Fire'});
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'goblet') RETURN node.title;
---- 1
Harry Potter and the Goblet of Fire
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'dragons') RETURN node.title;
---- 1
Harry Potter and the Goblet of Fire
-STATEMENT CALL _DROP_FTS_INDEX('Book', 'book_index_small');
---- error
Catalog exception: function _DROP_FTS_INDEX does not exist.
-STATEMENT CALL DROP_FTS_INDEX('Book', 'book_index_small');
---- ok
-STATEMENT CALL DROP_FTS_INDEX('Book', 'book_index');
---- ok

-STATEMENT CALL CREATE_FTS_INDEX('Book', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- ok
-STATEMENT CALL CREATE_FTS_INDEX('Book', 'book_index_small', ['abstract'], stemmer := 'porter');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'goblet') RETURN node.title;
---- 1
Harry Potter and the Goblet of Fire
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'goblet') RETURN node.title;
---- 0
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index_small', 'dragons') RETURN node.title;
---- 1
Harry Potter and the Goblet of Fire



-CASE Creation

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Book1 (ID SERIAL, abstract STRING, author STRING, title STRING, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE NODE TABLE Book2 (ID SERIAL, abstract STRING, author STRING, title STRING, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Book1 {abstract: 'An exploration of quantum mechanics.', author: 'Alice Johnson', title: 'The Quantum World'});
---- ok
-STATEMENT CREATE (b:Book2 {abstract: 'An introduction to machine learning techniques.', author: 'Emma Brown', title: 'Learning Machines'});
---- ok

# Build FTS on non-existent table
-STATEMENT CALL CREATE_FTS_INDEX('Book0', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- error
Binder exception: Table Book0 does not exist.

-STATEMENT CALL CREATE_FTS_INDEX('Book1', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- ok

# Build FTS with duplicate index name
-STATEMENT CALL CREATE_FTS_INDEX('Book1', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- error
Binder exception: Index book_index already exists in table Book1.

# Build FTS on non-existent property
-STATEMENT CALL CREATE_FTS_INDEX('Book1', 'book_index2', ['abstract', 'author', 'titlee'], stemmer := 'porter');
---- error
Binder exception: Property: titlee does not exist in table Book1.

-STATEMENT CALL CREATE_FTS_INDEX('Book2', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- ok

-STATEMENT CALL QUERY_FTS_INDEX('Book1', 'book_index', 'quantum machine') RETURN node.title;
---- 1
The Quantum World

-STATEMENT CALL QUERY_FTS_INDEX('Book2', 'book_index', 'quantum machine') RETURN node.title;
---- 1
Learning Machines

# Query FTS with incorrect index name
-STATEMENT CALL QUERY_FTS_INDEX('Book1', 'book_index_missing', 'quantum machine') RETURN node.title;
---- error
Binder exception: Table Book1 doesn't have an index with name book_index_missing.

# Query FTS with incorrect table name
-STATEMENT CALL QUERY_FTS_INDEX('Book0', 'book_index', 'quantum machine') RETURN node.title;
---- error
Binder exception: Table Book0 does not exist.



-CASE CaseSensitivity

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Documents (ID SERIAL, title STRING, text STRING, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Documents {title: 'six', text: 'Hello World'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'seven', text: 'heLLO woorld'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'eight', text: 'heLLO worlds'});
---- ok

-STATEMENT CALL CREATE_FTS_INDEX('Documents', 'documents_index', ['title', 'text'], stemmer := 'english');
---- ok

-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'world') RETURN node.title;
---- 2
six
eight



-CASE Stemming

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Documents (ID SERIAL, title STRING, text STRING, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Documents {title: 'one', text: ' quacking'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'two', text: ' quack'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'three', text: ' barked'});
---- ok

-STATEMENT CALL CREATE_FTS_INDEX('Documents', 'documents_index', ['text'], stemmer := 'english');
---- ok

-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'quacked') RETURN node.title;
---- 2
one
two



-CASE StopWords

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Documents (ID SERIAL, title STRING, text STRING, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Documents {title: 'four', text: 'the quick brown fox'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'five', text: 'quick fox'});
---- ok

-STATEMENT CALL CREATE_FTS_INDEX('Documents', 'documents_index', ['text'], stemmer := 'english');
---- ok

-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'the quick fox') RETURN node.title;
---- 2
four
five



-CASE SpecialCharacters

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Documents (ID SERIAL, title STRING, text STRING, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Documents {title: 'six', text: 'test.case'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'seven', text: 'test,case'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'eight', text: 'test-drive'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'nine', text: 'test case'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'ten', text: 'test.case'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'eleven', text: 'test,drive'});
---- ok
-STATEMENT CREATE (b:Documents {title: 'twelve', text: 'test-drive'});
---- ok

-STATEMENT CALL CREATE_FTS_INDEX('Documents', 'documents_index', ['text'], stemmer := 'english');
---- ok

-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'test-case', conjunctive := true) RETURN node.title;
---- 4
six
seven
nine
ten

-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'test-case', conjunctive := false) RETURN node.title;
---- 7
six
seven
eight
nine
ten
eleven
twelve

-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'test-drive', conjunctive := true) RETURN node.title;
---- 3
eight
eleven
twelve



-CASE DuplicateEntries

-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Documents (ID SERIAL, title STRING, text STRING, quantity INT64, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Documents {title: 'title1', text: 'test.case', quantity: 1});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title1', text: 'test.case', quantity: 2});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title2', text: 'test-drive', quantity: 3});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title2', text: 'test case', quantity: 4});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title3', text: 'test.case', quantity: 5});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title4', text: 'test drive', quantity: 6});
---- ok
-STATEMENT CALL CREATE_FTS_INDEX('Documents', 'documents_index', ['text'], stemmer := 'english');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'test-case', conjunctive := true) RETURN node.title;
---- 4
title1
title1
title2
title3
-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'test-case', conjunctive := true) RETURN node.quantity;
---- 4
1
2
4
5

-CASE InstallOfficialExtension
-SKIP
-SKIP_STATIC_LINK
-STATEMENT FORCE INSTALL fts FROM 'http://localhost/extension/repo/'
---- ok
-STATEMENT load fts
---- ok
-STATEMENT CALL CREATE_FTS_INDEX('Book', 'book_index', ['abstract', 'author', 'title'], stemmer := 'porter');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Book', 'book_index', 'a quantum machine') RETURN node.title;
---- 2
The Quantum World
Learning Machines

-CASE DropTableWithIndex
-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE NODE TABLE Documents (ID SERIAL, title STRING, text STRING, quantity INT64, PRIMARY KEY (ID));
---- ok
-STATEMENT CREATE (b:Documents {title: 'title1', text: 'test.case', quantity: 1});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title1', text: 'test.case', quantity: 2});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title2', text: 'test-drive', quantity: 3});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title2', text: 'test case', quantity: 4});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title3', text: 'test.case', quantity: 5});
---- ok
-STATEMENT CREATE (b:Documents {title: 'title4', text: 'test drive', quantity: 6});
---- ok
-STATEMENT CALL CREATE_FTS_INDEX('Documents', 'documents_index', ['text'], stemmer := 'english');
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('Documents', 'documents_index', 'test-case', conjunctive := true) RETURN node.title;
---- 4
title1
title1
title2
title3
-STATEMENT DROP TABLE Documents;
---- error
Binder exception: Cannot delete node table Documents because it is referenced by index documents_index.
-STATEMENT CALL DROP_FTS_INDEX('Documents', 'documents_index');
---- ok
-STATEMENT DROP TABLE Documents;
---- ok

-CASE InstallExtensionInStaticLink
-SKIP_DYNAMIC_LINK
-STATEMENT INSTALL fts
---- 1
Extension fts is already statically linked with the kuzu core. No need to INSTALL.
-STATEMENT load fts
---- 1
Extension fts is already statically linked with the kuzu core. No need to LOAD.
