@@ -52,7 +52,7 @@ public DocumentVSRepositoryBean(JdbcTemplate jdbcTemplate, EmbeddingModel embedd
5252 ObjectMapper objectMapper ) {
5353 this .jdbcTemplate = jdbcTemplate ;
5454 this .objectMapper = objectMapper ;
55- this .vectorStore = PgVectorStore .builder (). embeddingModel ( embeddingClient ).jdbcTemplate ( jdbcTemplate ). build ();
55+ this .vectorStore = PgVectorStore .builder (jdbcTemplate , embeddingClient ).build ();
5656 this .filterExpressionConverter = ((PgVectorStore ) this .vectorStore ).filterExpressionConverter ;
5757 this .vectorTableName = PgVectorStore .DEFAULT_TABLE_NAME ;
5858 }
@@ -64,24 +64,25 @@ public void add(List<Document> documents) {
6464
6565 @ Override
6666 public List <Document > retrieve (String query , DataType dataType , int k , double threshold ) {
67- return this .vectorStore
68- .similaritySearch ( SearchRequest
69- . query ( query ). withFilterExpression ( new Filter . Expression ( ExpressionType . EQ ,
70- new Key ( MetaData . DATATYPE ), new Value ( dataType . toString ())))
71- . withTopK ( k ). withSimilarityThreshold ( threshold ));
67+ return this .vectorStore . similaritySearch ( SearchRequest
68+ .builder (). query ( query ). filterExpression ( new Filter . Expression ( ExpressionType . EQ ,
69+ new Key ( MetaData . DATATYPE ), new Value ( dataType . toString ())))
70+ . topK ( k ). similarityThreshold ( threshold ). build ());
71+
7272 }
7373
7474 @ Override
7575 public List <Document > retrieve (String query , DataType dataType , int k ) {
76- return this .vectorStore .similaritySearch (SearchRequest .query (query ).withFilterExpression (
76+ return this .vectorStore .similaritySearch (SearchRequest .builder (). query (query ).filterExpression (
7777 new Filter .Expression (ExpressionType .EQ , new Key (MetaData .DATATYPE ), new Value (dataType .toString ())))
78- .withTopK ( k ));
78+ .topK ( k ). build ( ));
7979 }
8080
8181 @ Override
8282 public List <Document > retrieve (String query , DataType dataType ) {
83- return this .vectorStore .similaritySearch (SearchRequest .query (query ).withFilterExpression (
84- new Filter .Expression (ExpressionType .EQ , new Key (MetaData .DATATYPE ), new Value (dataType .toString ()))));
83+ return this .vectorStore .similaritySearch (SearchRequest .builder ().query (query ).filterExpression (
84+ new Filter .Expression (ExpressionType .EQ , new Key (MetaData .DATATYPE ), new Value (dataType .toString ())))
85+ .build ());
8586 }
8687
8788 @ Override
@@ -125,9 +126,9 @@ public Document mapRow(ResultSet rs, int rowNum) throws SQLException {
125126 PGobject embedding = rs .getObject (COLUMN_EMBEDDING , PGobject .class );
126127
127128 Map <String , Object > metadata = toMap (pgMetadata );
129+ metadata .put (COLUMN_EMBEDDING , this .toDoubleArray (embedding ));
128130
129131 Document document = new Document (id , content , metadata );
130- document .setEmbedding (toDoubleArray (embedding ));
131132
132133 return document ;
133134 }
@@ -146,6 +147,6 @@ private Map<String, Object> toMap(PGobject pgObject) {
146147 throw new RuntimeException (e );
147148 }
148149 }
149-
150150 }
151+
151152}
0 commit comments