From cba362ae138747cd8e7ec3deb28c7986e410d9aa Mon Sep 17 00:00:00 2001 From: Darek Date: Wed, 14 Oct 2026 18:29:59 +0200 Subject: [PATCH] test(fts): compare two indexes instead of pinning a score The phantom-document case in copy_ignore_errors.test pinned the BM25 score 0.353634, which would change with any scoring or data change. It now checks that the table holds the three surviving rows, builds a second index after the COPY and checks that both indexes score the document the same. Co-Authored-By: Claude Opus 5.5 --- fts/test/test_files/copy_ignore_errors.test | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fts/test/test_files/copy_ignore_errors.test b/fts/test/test_files/copy_ignore_errors.test index 6614730c..c51a2fd0 100644 --- a/fts/test/test_files/copy_ignore_errors.test +++ b/fts/test/test_files/copy_ignore_errors.test @@ -30,7 +30,8 @@ -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'cherry') RETURN node.id; ---- 0 -# A rejected row without indexable text must not be indexed with the previous row's text. +# A rejected row without indexable text must not be indexed with the previous row's text. The index +# maintained through the COPY must score like one built after it, which has no phantom document. -CASE CopySkipsDuplicateWithoutText -SKIP_IN_MEM -LOAD_DYNAMIC_EXTENSION fts @@ -38,22 +39,22 @@ ---- ok -STATEMENT CREATE (:Doc {id: 1, body: 'apple'}); ---- ok --STATEMENT CALL CREATE_FTS_INDEX('Doc', 'idx', ['body']); +-STATEMENT CALL CREATE_FTS_INDEX('Doc', 'during', ['body']); ---- ok -STATEMENT COPY (UNWIND [2, 1, 3] AS i RETURN i, CASE i WHEN 2 THEN 'banana cherry' WHEN 1 THEN '' ELSE 'date' END) TO '${LBUG_EXPORT_DB_DIRECTORY}_dup_empty.csv' (header=false); ---- ok -STATEMENT COPY Doc FROM '${LBUG_EXPORT_DB_DIRECTORY}_dup_empty.csv' (header=false, ignore_errors=true); ---- ok --STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'banana') RETURN node.id, score; +-STATEMENT MATCH (d:Doc) RETURN count(*); ---- 1 -2|0.353634 --STATEMENT CALL DROP_FTS_INDEX('Doc', 'idx'); ----- ok --STATEMENT CALL CREATE_FTS_INDEX('Doc', 'idx', ['body']); +3 +-STATEMENT CALL CREATE_FTS_INDEX('Doc', 'after', ['body']); ---- ok --STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'banana') RETURN node.id, score; +-STATEMENT CALL QUERY_FTS_INDEX('Doc', 'during', 'banana') WITH node.id AS id, score AS during + CALL QUERY_FTS_INDEX('Doc', 'after', 'banana') WITH id, during, node.id AS id2, score AS after + WHERE id = id2 RETURN id, abs(during - after) < 0.000001; ---- 1 -2|0.353634 +2|True # The rejected row is the last one in the file; rows written after the COPY stay deletable. -CASE CopyRejectsLastRow