From c83c3cd7967c2833d0b4fab63b8c7528532c7421 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 7 Sep 2022 14:11:44 +0200 Subject: [PATCH] Add a test to make sure that long words are correctly skipped --- milli/src/update/index_documents/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index 23618b478..365b0d024 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -1741,4 +1741,22 @@ mod tests { index.add_documents(doc3).unwrap_err(); index.add_documents(doc4).unwrap_err(); } + + #[test] + fn long_words_must_be_skipped() { + let index = TempIndex::new(); + + // this is obviousy too long + let long_word = "lol".repeat(1000); + let doc1 = documents! {[{ + "id": "1", + "title": long_word.clone(), + }]}; + + index.add_documents(doc1).unwrap(); + + let rtxn = index.read_txn().unwrap(); + let words_fst = index.words_fst(&rtxn).unwrap(); + assert!(!words_fst.contains(&long_word)); + } }