Skip to content

Commit

Permalink
Lowercase search term tokens (#117)
Browse files Browse the repository at this point in the history
* lowercase search term tokens

* apply spotless
  • Loading branch information
elliVM authored Nov 15, 2024
1 parent 39d6c62 commit 2b251b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public byte[] bytes() {
}
final BloomFilter filter = BloomFilter.create(expected, fpp);
for (final String token : stringTokens) {
filter.put(token);
filter.put(token.toLowerCase());
}
try (final ByteArrayOutputStream filterBAOS = new ByteArrayOutputStream()) {
filter.writeTo(filterBAOS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testRegexExtractedTokens() {
byte[] bytes = Assertions.assertDoesNotThrow(filter::bytes);
BloomFilter resultFilter = Assertions
.assertDoesNotThrow(() -> BloomFilter.readFrom(new ByteArrayInputStream(bytes)));
Assertions.assertTrue(resultFilter.mightContain("Pattern"));
Assertions.assertTrue(resultFilter.mightContain("pattern"));
}

@Test
Expand All @@ -110,9 +110,10 @@ public void testTokenizerTokens() {
byte[] bytes = Assertions.assertDoesNotThrow(filter::bytes);
BloomFilter resultFilter = Assertions
.assertDoesNotThrow(() -> BloomFilter.readFrom(new ByteArrayInputStream(bytes)));
Assertions.assertFalse(resultFilter.mightContain("Pattern"));
Assertions.assertTrue(resultFilter.mightContain("Without"));
Assertions.assertTrue(resultFilter.mightContain("SearchValuePatternInThisString"));
// test that tokens present and in lower case
Assertions.assertFalse(resultFilter.mightContain("pattern"));
Assertions.assertTrue(resultFilter.mightContain("without"));
Assertions.assertTrue(resultFilter.mightContain("searchvaluepatterninthisstring"));
}

@Test
Expand Down

0 comments on commit 2b251b1

Please sign in to comment.