Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redis.om.spring.annotations.document.vectorize;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;
import static org.junit.jupiter.api.Assertions.assertAll;

import java.io.IOException;
Expand Down Expand Up @@ -89,7 +90,9 @@ void testKnnSentenceSimilaritySearch() {
.limit(K) //
.collect(Collectors.toList());

assertThat(results).hasSize(5).map(DocWithOllamaEmbedding::getName).containsExactly( //
assertThat(results).hasSize(5);
assertThat(results.get(0).getName()).isEqualTo("cat"); // Exact match should be first
assertThat(results).map(DocWithOllamaEmbedding::getName).containsExactlyInAnyOrder( //
"cat", "dog", "lion", "elephant", "giraffe" //
);
}
Expand Down Expand Up @@ -136,10 +139,11 @@ void testKnnSentenceSimilaritySearchWithScores() {
.collect(Collectors.toList());

assertAll( //
() -> assertThat(results).hasSize(5).map(Pair::getFirst).map(DocWithOllamaEmbedding::getName).containsExactly(
() -> assertThat(results).hasSize(5), //
() -> assertThat(results.get(0).getFirst().getName()).isEqualTo("cat"), // Exact match should be first
() -> assertThat(results).map(Pair::getFirst).map(DocWithOllamaEmbedding::getName).containsExactlyInAnyOrder(
"cat", "dog", "lion", "elephant", "giraffe"), //
() -> assertThat(results).hasSize(5).map(Pair::getSecond).usingElementComparator(closeToComparator)
.containsExactly(1.78813934326E-7, 0.301205277443, 0.315115869045, 0.338551998138, 0.407371640205) //
() -> assertThat(results.get(0).getSecond()).isCloseTo(0.0, within(0.001)) // Cat should have ~0 distance to itself
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redis.om.spring.annotations.hash.vectorize;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;
import static org.junit.jupiter.api.Assertions.assertAll;

import java.io.IOException;
Expand Down Expand Up @@ -89,7 +90,9 @@ void testKnnSentenceSimilaritySearch() {
.limit(K) //
.collect(Collectors.toList());

assertThat(results).hasSize(5).map(HashWithOllamaEmbedding::getName).containsExactly( //
assertThat(results).hasSize(5);
assertThat(results.get(0).getName()).isEqualTo("cat"); // Exact match should be first
assertThat(results).map(HashWithOllamaEmbedding::getName).containsExactlyInAnyOrder( //
"cat", "dog", "lion", "elephant", "giraffe" //
);
}
Expand Down Expand Up @@ -136,10 +139,11 @@ void testKnnSentenceSimilaritySearchWithScores() {
.collect(Collectors.toList());

assertAll( //
() -> assertThat(results).hasSize(5).map(Pair::getFirst).map(HashWithOllamaEmbedding::getName).containsExactly(
() -> assertThat(results).hasSize(5), //
() -> assertThat(results.get(0).getFirst().getName()).isEqualTo("cat"), // Exact match should be first
() -> assertThat(results).map(Pair::getFirst).map(HashWithOllamaEmbedding::getName).containsExactlyInAnyOrder(
"cat", "dog", "lion", "elephant", "giraffe"), //
() -> assertThat(results).hasSize(5).map(Pair::getSecond).usingElementComparator(closeToComparator)
.containsExactly(1.78813934326E-7, 0.301205277443, 0.315115869045, 0.338551998138, 0.407371640205) //
() -> assertThat(results.get(0).getSecond()).isCloseTo(0.0, within(0.001)) // Cat should have ~0 distance to itself
);
}

Expand Down