153153 * @author Sebastien Deleuze
154154 * @author Jihoon Kim
155155 * @author YeongMin Song
156+ * @author Jonghoon Park
156157 * @since 1.0.0
157158 */
158159public class PgVectorStore extends AbstractObservationVectorStore implements InitializingBean {
@@ -202,6 +203,8 @@ public class PgVectorStore extends AbstractObservationVectorStore implements Ini
202203
203204 private final ObjectMapper objectMapper ;
204205
206+ private final DocumentRowMapper documentRowMapper ;
207+
205208 private final boolean removeExistingVectorStoreTable ;
206209
207210 private final PgIndexType createIndexMethod ;
@@ -219,6 +222,7 @@ protected PgVectorStore(PgVectorStoreBuilder builder) {
219222 Assert .notNull (builder .jdbcTemplate , "JdbcTemplate must not be null" );
220223
221224 this .objectMapper = JsonMapper .builder ().addModules (JacksonUtils .instantiateAvailableModules ()).build ();
225+ this .documentRowMapper = new DocumentRowMapper (this .objectMapper );
222226
223227 String vectorTable = builder .vectorTableName ;
224228 this .vectorTableName = vectorTable .isEmpty () ? DEFAULT_TABLE_NAME : vectorTable .trim ();
@@ -372,7 +376,7 @@ public List<Document> doSimilaritySearch(SearchRequest request) {
372376 return this .jdbcTemplate .query (
373377 String .format (this .getDistanceType ().similaritySearchSqlTemplate , getFullyQualifiedTableName (),
374378 jsonPathFilter ),
375- new DocumentRowMapper ( this .objectMapper ) , queryEmbedding , queryEmbedding , distance , request .getTopK ());
379+ this .documentRowMapper , queryEmbedding , queryEmbedding , distance , request .getTopK ());
376380 }
377381
378382 public List <Double > embeddingDistance (String query ) {
@@ -599,8 +603,6 @@ public enum PgDistanceType {
599603
600604 private static class DocumentRowMapper implements RowMapper <Document > {
601605
602- private static final String COLUMN_EMBEDDING = "embedding" ;
603-
604606 private static final String COLUMN_METADATA = "metadata" ;
605607
606608 private static final String COLUMN_ID = "id" ;
0 commit comments