153
153
* @author Sebastien Deleuze
154
154
* @author Jihoon Kim
155
155
* @author YeongMin Song
156
+ * @author Jonghoon Park
156
157
* @since 1.0.0
157
158
*/
158
159
public class PgVectorStore extends AbstractObservationVectorStore implements InitializingBean {
@@ -202,6 +203,8 @@ public class PgVectorStore extends AbstractObservationVectorStore implements Ini
202
203
203
204
private final ObjectMapper objectMapper ;
204
205
206
+ private final DocumentRowMapper documentRowMapper ;
207
+
205
208
private final boolean removeExistingVectorStoreTable ;
206
209
207
210
private final PgIndexType createIndexMethod ;
@@ -219,6 +222,7 @@ protected PgVectorStore(PgVectorStoreBuilder builder) {
219
222
Assert .notNull (builder .jdbcTemplate , "JdbcTemplate must not be null" );
220
223
221
224
this .objectMapper = JsonMapper .builder ().addModules (JacksonUtils .instantiateAvailableModules ()).build ();
225
+ this .documentRowMapper = new DocumentRowMapper (this .objectMapper );
222
226
223
227
String vectorTable = builder .vectorTableName ;
224
228
this .vectorTableName = vectorTable .isEmpty () ? DEFAULT_TABLE_NAME : vectorTable .trim ();
@@ -372,7 +376,7 @@ public List<Document> doSimilaritySearch(SearchRequest request) {
372
376
return this .jdbcTemplate .query (
373
377
String .format (this .getDistanceType ().similaritySearchSqlTemplate , getFullyQualifiedTableName (),
374
378
jsonPathFilter ),
375
- new DocumentRowMapper ( this .objectMapper ) , queryEmbedding , queryEmbedding , distance , request .getTopK ());
379
+ this .documentRowMapper , queryEmbedding , queryEmbedding , distance , request .getTopK ());
376
380
}
377
381
378
382
public List <Double > embeddingDistance (String query ) {
@@ -599,8 +603,6 @@ public enum PgDistanceType {
599
603
600
604
private static class DocumentRowMapper implements RowMapper <Document > {
601
605
602
- private static final String COLUMN_EMBEDDING = "embedding" ;
603
-
604
606
private static final String COLUMN_METADATA = "metadata" ;
605
607
606
608
private static final String COLUMN_ID = "id" ;
0 commit comments