-DATASET CSV fts-small

--

-DEFINE_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX [
-STATEMENT CALL QUERY_FTS_INDEX('doc', 'docIdx', 'alice waterloo') RETURN node.author, score
---- 2
alice|0.294468
alice|0.219056
]

-DEFINE_STATEMENT_BLOCK VALIDATE_NAME_STOPWORDS_IDX [
-STATEMENT CALL QUERY_FTS_INDEX('doc', 'docIdx1', 'alice waterloo') RETURN node.author, score
---- 2
alice|0.204120
bob|0.191091
# Note: is and in are no longer stopwords
-STATEMENT CALL QUERY_FTS_INDEX('doc', 'docIdx1', 'in') RETURN node.author, score
---- 2
alice|0.204120
alice|0.219056
-STATEMENT CALL QUERY_FTS_INDEX('doc', 'docIdx1', 'is') RETURN node.author, score
---- 1
alice|0.457137
]

-DEFINE_STATEMENT_BLOCK VALIDATE_SHOW_INDEXES [
-STATEMENT CALL SHOW_INDEXES() RETURN *;
---- 2
doc|docIdx1|FTS|[content,author,name]|True|CALL CREATE_FTS_INDEX('doc', 'docIdx1', ['content', 'author', 'name'], stemmer := 'porter', stopWords := 'name_stopwords');
doc|docIdx|FTS|[content,author,name]|True|CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stemmer := 'porter', stopWords := 'city_stopwords');
]

-CASE CustomizedStopWordsTable
-LOAD_DYNAMIC_EXTENSION fts
-LOG CityStopWordsTable
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 'city_stopwords', stemmer := 'porter')
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX

-STATEMENT DROP TABLE city_stopwords;
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX

-LOG NameStopWordsTable
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx1', ['content', 'author', 'name'], stopWords := 'name_stopwords', stemmer := 'porter')
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_NAME_STOPWORDS_IDX

-STATEMENT ALTER TABLE name_stopwords RENAME TO city_stopwords1;
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX

-INSERT_STATEMENT_BLOCK VALIDATE_SHOW_INDEXES

-STATEMENT EXPORT DATABASE '${KUZU_EXPORT_DB_DIRECTORY}_fts/stopwords_export_test'
---- ok
-RELOADDB
-IMPORT_DATABASE "${KUZU_EXPORT_DB_DIRECTORY}_fts/stopwords_export_test"
-STATEMENT IMPORT DATABASE '${KUZU_EXPORT_DB_DIRECTORY}_fts/stopwords_export_test'
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX

-CASE CustomizedStopWordsFile
-LOAD_DYNAMIC_EXTENSION fts
-LOG CityStopWordsFile
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := '${KUZU_ROOT_DIRECTORY}/dataset/fts-small/city_stopwords.csv', stemmer := 'porter')
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX
-LOG NameStopWordsFile
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx1', ['content', 'author', 'name'], stopWords := '${KUZU_ROOT_DIRECTORY}/dataset/fts-small/name_stopwords.csv', stemmer := 'porter')
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_NAME_STOPWORDS_IDX

-CASE CustomizedStopWordTableError
-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := '${KUZU_ROOT_DIRECTORY}/dataset/fts-small/city_stopwords1.csv', stemmer := 'porter')
---- error
Binder exception: Given stopwords: '${KUZU_ROOT_DIRECTORY}/dataset/fts-small/city_stopwords1.csv' is not a node table name nor a valid file path.
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 'likes', stemmer := 'porter')
---- error
Binder exception: The stop words table must be a node table.
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 'INVALID_STOPWORDS', stemmer := 'porter')
---- error
Binder exception: The stop words table must have exactly one string column.
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 'INVALID_STOPWORDS_COL_TYPE', stemmer := 'porter')
---- error
Binder exception: The stop words table must have exactly one string column.
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 'S3://kuzu-test/test123', stemmer := 'porter')
---- error
Binder exception: Given stopwords: 'S3://kuzu-test/test123' is not a node table name nor a valid file path.

-CASE StopWordsTableFileOnS3
# In-memory mode doesn't support file cache.
-SKIP_IN_MEM
-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 's3://kuzu-test/fts/city_stopwords.csv', stemmer := 'porter')
---- error
Binder exception: Given stopwords: 's3://kuzu-test/fts/city_stopwords.csv' is not a node table name nor a valid file path.
-LOAD_DYNAMIC_EXTENSION httpfs
-STATEMENT CALL s3_access_key_id='${UW_S3_ACCESS_KEY_ID}'
---- ok
-STATEMENT CALL s3_secret_access_key='${UW_S3_SECRET_ACCESS_KEY}'
---- ok
-STATEMENT CALL s3_endpoint='rgw.cs.uwaterloo.ca'
---- ok
-STATEMENT CALL s3_url_style='path'
---- ok
-STATEMENT CALL s3_region='US'
---- ok
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := 's3://kuzu-test/fts/city_stopwords.csv', stemmer := 'porter')
---- ok
-INSERT_STATEMENT_BLOCK VALIDATE_CITY_STOPWORDS_IDX

-CASE UTF8StopWords
-LOAD_DYNAMIC_EXTENSION fts
-STATEMENT CREATE (d:doc {ID: 100, content: '这是一个有趣的故事', author: '小明', name: '一本书'})
---- ok
-STATEMENT CREATE (d:doc {ID: 101, content: '有趣', author: '小红', name: '故事'})
---- ok
-STATEMENT CALL CREATE_FTS_INDEX('doc', 'docIdx', ['content', 'author', 'name'], stopWords := '${KUZU_ROOT_DIRECTORY}/dataset/fts-small/utf8_stopwords.csv', stemmer := 'porter')
---- ok
-STATEMENT CALL QUERY_FTS_INDEX('doc', 'docIdx', '小明 有趣') RETURN node.author, score
---- 1
小明|0.743224
-STATEMENT CALL QUERY_FTS_INDEX('doc', 'docIdx', '有趣') RETURN node.author, score
---- 0
