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
Expand Up @@ -39,7 +39,6 @@
import com.oracle.bedrock.testsupport.junit.TestLogsExtension;
import com.tangosol.net.Coherence;
import com.tangosol.net.Session;
import org.junit.Assert;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand All @@ -64,6 +63,7 @@
import org.springframework.util.CollectionUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

@Disabled("Crashes on github actions run")
public class CoherenceVectorStoreIT {
Expand Down Expand Up @@ -132,7 +132,7 @@ public void addAndSearch(CoherenceVectorStore.DistanceType distanceType, Coheren
assertThat(resultDoc.getMetadata()).containsKeys("meta2", DocumentMetadata.DISTANCE.value());

// Remove all documents from the store
vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList());
vectorStore.delete(this.documents.stream().map(Document::getId).toList());

List<Document> results2 = vectorStore
.similaritySearch(SearchRequest.builder().query("Great Depression").topK(1).build());
Expand Down Expand Up @@ -204,15 +204,10 @@ public void searchWithFilters(CoherenceVectorStore.DistanceType distanceType,

assertThat(results).hasSize(1);
assertThat(results.get(0).getId()).isEqualTo(bgDocument2.getId());

try {
vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build());
Assert.fail("Invalid filter expression should have been cached!");
}
catch (FilterExpressionTextParser.FilterExpressionParseException e) {
assertThat(e.getMessage()).contains("Line: 1:17, Error: no viable alternative at input 'NL'");
}
assertThatExceptionOfType(FilterExpressionTextParser.FilterExpressionParseException.class)
.isThrownBy(() -> vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build()))
.withMessageContaining("Line: 1:17, Error: no viable alternative at input 'NL'");

// Remove all documents from the store
truncateMap(context, ((CoherenceVectorStore) vectorStore).getMapName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import javax.sql.DataSource;

import com.zaxxer.hikari.HikariDataSource;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -50,7 +49,7 @@
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.vectorstore.filter.Filter;
import org.springframework.ai.vectorstore.filter.FilterExpressionTextParser.FilterExpressionParseException;
import org.springframework.ai.vectorstore.filter.FilterExpressionTextParser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Expand All @@ -66,6 +65,7 @@
import org.springframework.util.CollectionUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
* @author Diego Dupin
Expand Down Expand Up @@ -170,7 +170,7 @@ public void addAndSearch(String distanceType) {
assertThat(resultDoc.getScore()).isBetween(0.0, 1.0);

// Remove all documents from the store
vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList());
vectorStore.delete(this.documents.stream().map(Document::getId).toList());

List<Document> results2 = vectorStore
.similaritySearch(SearchRequest.builder().query("Great Depression").topK(1).build());
Expand Down Expand Up @@ -282,14 +282,10 @@ public void searchWithFilters(String distanceType) {
assertThat(results).hasSize(1);
assertThat(results.get(0).getId()).isEqualTo(bgDocument.getId());

try {
vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build());
Assert.fail("Invalid filter expression should have been cached!");
}
catch (FilterExpressionParseException e) {
assertThat(e.getMessage()).contains("Line: 1:17, Error: no viable alternative at input 'NL'");
}
assertThatExceptionOfType(FilterExpressionTextParser.FilterExpressionParseException.class)
.isThrownBy(() -> vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build()))
.withMessageContaining("Line: 1:17, Error: no viable alternative at input 'NL'");

// Remove all documents from the store
dropTable(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import javax.sql.DataSource;

import oracle.jdbc.pool.OracleDataSource;
import org.junit.Assert;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -65,6 +64,7 @@
import org.springframework.util.CollectionUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

@Testcontainers
@Disabled("Oracle image is 2GB")
Expand Down Expand Up @@ -155,7 +155,7 @@ public void addAndSearch(String distanceType) {
assertThat(resultDoc.getMetadata()).containsKeys("meta2", DocumentMetadata.DISTANCE.value());

// Remove all documents from the store
vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList());
vectorStore.delete(this.documents.stream().map(Document::getId).toList());

List<Document> results2 = vectorStore
.similaritySearch(SearchRequest.builder().query("Great Depression").topK(1).build());
Expand Down Expand Up @@ -237,14 +237,10 @@ public void searchWithFilters(String distanceType, int searchAccuracy) {
assertThat(results).hasSize(1);
assertThat(results.get(0).getId()).isEqualTo(bgDocument.getId());

try {
vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build());
Assert.fail("Invalid filter expression should have been cached!");
}
catch (FilterExpressionTextParser.FilterExpressionParseException e) {
assertThat(e.getMessage()).contains("Line: 1:17, Error: no viable alternative at input 'NL'");
}
assertThatExceptionOfType(FilterExpressionTextParser.FilterExpressionParseException.class)
.isThrownBy(() -> vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build()))
.withMessageContaining("Line: 1:17, Error: no viable alternative at input 'NL'");

// Remove all documents from the store
dropTable(context, ((OracleVectorStore) vectorStore).getTableName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import javax.sql.DataSource;

import com.zaxxer.hikari.HikariDataSource;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -51,7 +50,7 @@
import org.springframework.ai.test.vectorstore.BaseVectorStoreTests;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.vectorstore.filter.FilterExpressionTextParser.FilterExpressionParseException;
import org.springframework.ai.vectorstore.filter.FilterExpressionTextParser;
import org.springframework.ai.vectorstore.pgvector.PgVectorStore.PgIdType;
import org.springframework.ai.vectorstore.pgvector.PgVectorStore.PgIndexType;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -69,6 +68,7 @@
import org.springframework.util.CollectionUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
* @author Muthukumaran Navaneethakrishnan
Expand Down Expand Up @@ -173,7 +173,7 @@ public void addAndSearch(String distanceType) {
assertThat(resultDoc.getMetadata()).containsKeys("meta2", DocumentMetadata.DISTANCE.value());

// Remove all documents from the store
vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList());
vectorStore.delete(this.documents.stream().map(Document::getId).toList());

List<Document> results2 = vectorStore
.similaritySearch(SearchRequest.builder().query("Great Depression").topK(1).build());
Expand Down Expand Up @@ -382,14 +382,10 @@ public void searchWithFilters(String distanceType) {
assertThat(results).hasSize(1);
assertThat(results.get(0).getId()).isEqualTo(bgDocument.getId());

try {
vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build());
Assert.fail("Invalid filter expression should have been cached!");
}
catch (FilterExpressionParseException e) {
assertThat(e.getMessage()).contains("Line: 1:17, Error: no viable alternative at input 'NL'");
}
assertThatExceptionOfType(FilterExpressionTextParser.FilterExpressionParseException.class)
.isThrownBy(() -> vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build()))
.withMessageContaining("Line: 1:17, Error: no viable alternative at input 'NL'");

// Remove all documents from the store
dropTable(context);
Expand Down